bit.io Python SDK and CLI
Project description
bit.io Python SDK & Command Line Tool
bitdotio module
The v2 SDK currently only supports generation of pre-configured psycopg2
connections
to v2 bit.io. We plan to add further SDK operations as we begin expanding the
bit.io Developer API.
Example v2 usage:
#!/usr/bin/env python3
import bitdotio
from pprint import pprint
# Instantiate a bit.io client for connecting to databases
b = bitdotio.bitdotio(<YOUR_API_KEY>)
# Connect to a database by name
conn = b.get_connection(<YOUR_DATABASE_NAME>)
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 opening the "Connect" tab on a database page.
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(<YOUR_DATABASE_NAME>)
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.
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-2.0.0b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eba929837e01d88e90180edd6d6bd94ec8d36ea43e316f57378315840aecb287 |
|
MD5 | 620f5beed8742dc11c3cf741e1c20f2d |
|
BLAKE2b-256 | 624153f6e0a277729067450563a36c0aa4ec3c24a64a20b03a355071eb119a62 |