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

Migrate SQL queries to SQLAlchemy for compat between sqlite and mysql #202

Open
arrrobase opened this issue Feb 26, 2020 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@arrrobase
Copy link
Member

No description provided.

@arrrobase arrrobase added the enhancement New feature or request label Feb 26, 2020
@arrrobase arrrobase self-assigned this Feb 26, 2020
@arrrobase
Copy link
Member Author

arrrobase commented Feb 26, 2020

Also need to add a context manager to close connections after queries. Something like this:

from nems.db import Session

@contextmanager
def db_session():
    session = Session()
    try:
        yield session
        session.commit()
    except:
         session.rollback()
    finally:
         session.close()

with db_session() as session:
    session.add(object)

https://docs.sqlalchemy.org/en/13/orm/session_basics.html

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

No branches or pull requests

1 participant