Python—SQLAlchemy
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.
from sqlalchemy import create_engine
## MAKE THIS IMPORTANT CHANGE TO USE AUTOCOMMIT TRANSACTIONS WITH BIT.IO
eng=create_engine('<YOUR_POSTGRESQL_STRING>', isolation_level="AUTOCOMMIT")
# Work with sqlalchemy as you normally would
with eng.connect() as conn:
result = conn.execute("SELECT 1;")
print(result.first()[0])
Updated 11 months ago