Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use .env to connect in sqlalchemy #64

Open
wanghaisheng opened this issue Jun 27, 2024 · 1 comment
Open

how to use .env to connect in sqlalchemy #64

wanghaisheng opened this issue Jun 27, 2024 · 1 comment

Comments

@wanghaisheng
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants