bit.io works with https://www.sqlalchemy.org/ since it speaks standard postgres. To get started, install sqlalchemy and the associated postgres DBAPI package.
If you have postgres already installed locally, you can run the following:
pip install sqlalchemy, psycopg2
If you do not have postgresql installed locally, install
psycopg2-binary instead so that you have the necessary dependencies to work with postgres.
pip install sqlalchemy, psycopg2-binary
If necessary, see https://docs.sqlalchemy.org/en/14/intro.html#installation-guide for more details on how to install sqlalchemy.
Once you have sqlalchemy installed, you can connect it to bit.io as though it is standard postgres. Because bit.io does not yet support transactions, you must use the
AUTOCOMMIT transaction mode. For example,
from sqlalchemy import create_engine ## MAKE THIS IMPORTANT CHANGE TO USE AUTOCOMMIT TRANSACTIONS WITH BIT.IO eng=create_engine('postgresql://dliden-test:[email protected]/dliden-test/dltest', isolation_level="AUTOCOMMIT") # Work with sqlalchemy as you normally would with eng.connect() as conn: result = conn.execute("SELECT 1;") print(result.first())
Updated about 2 months ago