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

Global session object is bad practice #12

Closed
JBorrow opened this issue Jan 11, 2024 · 1 comment · Fixed by #24
Closed

Global session object is bad practice #12

JBorrow opened this issue Jan 11, 2024 · 1 comment · Fixed by #24
Assignees
Labels
librarian-v2 Changes for Version 2
Milestone

Comments

@JBorrow
Copy link
Member

JBorrow commented Jan 11, 2024

Right now we are using a global SQLAlchemy Session object for all transactions:

SessionMaker = sessionmaker(bind=engine, autocommit=False, autoflush=False)
session = SessionMaker()

This should be changed so we use SesssionMaker() within each request using Depends in FastAPI: https://fastapi.tiangolo.com/tutorial/sql-databases/.

It may also be worth migrating to SQLModel (which uses pydantic & SQLAlchemy).

@JBorrow JBorrow added the librarian-v2 Changes for Version 2 label Jan 11, 2024
@JBorrow JBorrow added this to the Deployment milestone Jan 19, 2024
@JBorrow JBorrow self-assigned this Jan 22, 2024
JBorrow added a commit that referenced this issue Jan 22, 2024
@JBorrow JBorrow linked a pull request Jan 22, 2024 that will close this issue
@JBorrow
Copy link
Member Author

JBorrow commented Jan 23, 2024

@plaplant Let me know your thoughts on this if any, otherwise I will just go ahead and merge

@JBorrow JBorrow closed this as completed Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
librarian-v2 Changes for Version 2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant