bit.io Python SDK
Reason this release was yanked:
No longer functional.
Project description
bit.io Python SDK
Example usage:
#!/usr/bin/env python3
import bitdotio
from pprint import pprint
# Connect to bit.io
b = bitdotio.bitdotio(<YOUR_API_KEY>)
# Let's see your repos
pprint(b.list_repos())
# How about some database queries?
conn = b.get_connection()
cur = conn.cursor()
cur.execute("SELECT 1")
pprint(cur.fetchone())
Requirements
In order to support different environments, we have a few ways to install the bitdotio package
with or without the psycopg2
dependency.
- If you already have
psycopg2
installed, you can install the default bitdotio package:
pip install bitdotio
- If you already have Postgres installed, you can install with the psycopg2 dependency:
pip install 'bitdotio[psycopg2]'
- If you do not have or cannot install Postgres, you can install with the psycopg2-binary dependency:
pip install 'bitdotio[psycopg2-binary]'
Install Postgres
To install Postgres on Windows, go to https://www.postgresql.org/download/ and download the version that is correct for your computer, or use your operating system's preferred package manager.
After you have Postgres installed you can install this library with pip install bitdotio[psycopg2]
.
Usage
Once you have bitdotio
installed all you need is your API key to start working with bit.io.
You can get your API key by logging into bit.io and scrolling down to the "Connect any data tool" box, clicking on "API/SDK", and copying the key from there.
See https://docs.bit.io/docs/connecting-to-bitio screenshots and examples.
Python DB-API usage
bitdotio
provides easy Python access to querying your data with just a bit.io API key:
#!/usr/bin/env python3
import bitdotio
# Connect to bit.io
b = bitdotio.bitdotio(<YOUR_API_KEY>)
conn = b.get_connection()
cur = conn.cursor()
cur.execute("SELECT 1")
print(cur.fetchone())
The connection and cursor provided by bitdotio
are fully Python DB-API compatible, are in fact Pyscopg2 connections and cursors.
Full documentation on Psycopg2 can be found on https://www.psycopg.org/docs/usage.html
bit.io usage
bitdotio
can also do almost everything you can do on bit.io's main site.
#!/usr/bin/env python3
import bitdotio
from pprint import pprint
# Connect to bit.io
b = bitdotio.bitdotio(<YOUR_API_KEY>)
# Let's see your repos
pprint(b.list_repos())
You can use the SDK to create/update/delete repos and query data. In general the SDK is fully mapped to the REST API; the documentation for the REST API is availble at https://docs.bit.io/reference
bit.io concepts
bit.io is a database, with extra features like easy sharing and collaboration. We have a few concepts that the SDK works with:
- Repostories ("repos") - a schema, in Postgres terms, that contains tables and columns. You can have public and private repositories, and you can write SQL that joins any repo you have access to with another repo. A repo contains tables, and tables contain columns.
Detailed documentation on interacting with each concept with the SDK:
SDK Reference
Class | Method | HTTP request | Description |
---|---|---|---|
ApiBitdotio | create_query_result | POST /query/ | |
ApiBitdotio | create_repo | POST /users/{user_username}/repos/ | |
ApiBitdotio | destroy_repo | DELETE /users/{user_username}/repos/{name}/ | |
ApiBitdotio | list_repos | GET /users/{user_username}/repos/ | |
ApiBitdotio | partial_update_repo | PATCH /users/{user_username}/repos/{name}/ | |
ApiBitdotio | retrieve_repo | GET /users/{user_username}/repos/{name}/ | |
ApiBitdotio | update_repo | PUT /users/{user_username}/repos/{name}/ |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bitdotio-1.0.0b5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b416833e15d701feae913821fcdd3adb355cb665f47a1e1285e9247867b53b2 |
|
MD5 | f07ed9b6ce1c9aab2e05c1218719a569 |
|
BLAKE2b-256 | 9b035febed62e3cc93f77abe3a34c18976f353e76f38f53bbd563abfe8ec2361 |