tursodatabase / libsql-experimental-python

libSQL API for Python (experimental)
99 stars 10 forks source link

how to use .env to connect in sqlalchemy #64

Open wanghaisheng opened 4 months ago

wanghaisheng commented 4 months ago

from sqlalchemy import create_engine import os

url = os.getenv("TURSO_DATABASE_URL") auth_token = os.getenv("TURSO_AUTH_TOKEN")

engine = create_engine("sqlite+libsql://", echo=True)

Base.metadata.create_all(engine)

then if i set this to local db, after process how to sync to cloud like conn.sync()

nikhil-swamix commented 3 months ago

create a turso client along with engine, and use the sqlalchemy default file as input to the turso client, currently i dont found another way, please let me know if it works.