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

SQLite code does not use context manager #37

Open
expectocode opened this issue May 16, 2019 · 1 comment
Open

SQLite code does not use context manager #37

expectocode opened this issue May 16, 2019 · 1 comment

Comments

@expectocode
Copy link

Instead of

conn = self._conn()
cursor = conn.cursor()
cursor.execute(<some sql>)
conn.commit()

we can do:

conn = self._conn()
with conn:
    conn.execute(<some sql>)

which also handles rollbacks. Would you accept a PR to this effect?

@AntonOfTheWoods
Copy link

If memory serves, sqlite3 has some quirks compared with other common DB2 libs, and doesn't provide context managers for some things (cursors?). The code is supposed to be generic enough now to support other RDBMSes, so reintroducing sqlite3-specific code would break that, and my heart :-).
That said, I think I did try and use with where possible/sensible when I refactored the code a few months ago, so that may just be an oversight on my part.

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