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

Expose sqlalchemy engine in global DBOS class #195

Open
nnayr opened this issue Jan 31, 2025 · 2 comments
Open

Expose sqlalchemy engine in global DBOS class #195

nnayr opened this issue Jan 31, 2025 · 2 comments

Comments

@nnayr
Copy link

nnayr commented Jan 31, 2025

It would be useful to export the sqlalchemy engine initialized here: https://github.com/dbos-inc/dbos-transact-py/blob/main/dbos/_app_db.py#L63 in the DBOS global instance. This would prevent needing to initialize a new engine to perform database operations outside of @DBOS.transaction steps.

@kraftp
Copy link
Member

kraftp commented Jan 31, 2025

Got it! Just to be clear, while that's possible, that engine uses the default (synchronous) driver, so this doesn't resolve #190. Also, one useful method for creating your own engine is get_dbos_database_url.

@nnayr
Copy link
Author

nnayr commented Feb 1, 2025

Yeah, I used that helper function to initialize a new engine. I'm not well versed in python and the state of its asyncio. Just thought this could be a useful feature since each engine is costly with its own connection pool.

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