If you are primarily interested in using
pandaswith bit.io, check out our other section Connecting via pandas.
pip install bitdotio
#!/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())
bitdotio requires a local installation of PostgreSQL, version 12 or greater. This is because the
underlying connection management library is
psycopg2 which links against the PostgreSQL library.
To install Postgres on Windows, go to https://www.postgresql.org/download/ and download the version
that is correct for your computer.
On MacOS, Postgres can be installed via Brew:
brew install postgres
Similarly, on linux machines, Postgres can be installed via your distribution's package manager:
sudo apt install postgresql
After you have Postgres installed you can install this library via
pip install bitdotio.
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, clicking "Connect" and then "API / SDK".
See https://docs.bit.io/docs/connecting-to-bitio screenshots and examples.
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, as they are in fact Pyscopg2 connections and cursors.
Full documentation on Psycopg2 can be found on https://www.psycopg.org/docs/usage.html
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, tables, columns & endpoints; query data; and share repos. In general the SDK is fully mapped to the REST API. The API docs are available at https://docs.bit.io/reference.
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 table you have access to within the same repo. A repo contains tables, and tables contain columns.
For detailed documentation on each of the SDK methods and concepts, see the documentation on the package home page https://pypi.org/project/bitdotio/
Updated 11 months ago