diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-15 20:04:19 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-24 20:25:01 +0000 |
commit | e9078e0bb6ea597adbeaab406ccf965dc9cb38fc (patch) | |
tree | a099061be95a4a57e7eb05cc37cdc7acc7e3ec65 | |
parent | 90bd38200c865fe3e2a3f41d41205334f6a7adb5 (diff) | |
download | paste-e9078e0bb6ea597adbeaab406ccf965dc9cb38fc.tar.gz paste-e9078e0bb6ea597adbeaab406ccf965dc9cb38fc.tar.xz paste-e9078e0bb6ea597adbeaab406ccf965dc9cb38fc.zip |
do not shorten connection to conn in the db API
-rw-r--r-- | paste/db.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/paste/db.py b/paste/db.py index 6671a12..692b01f 100644 --- a/paste/db.py +++ b/paste/db.py @@ -44,28 +44,28 @@ def _data_hash_udf(b: Union[bytes, str]) -> bytes: return blake2b(b, digest_size=32).digest() -def get_version(conn: sqlite3.Connection) -> int: - (user_version,) = conn.execute("PRAGMA user_version").fetchone() +def get_version(connection: sqlite3.Connection) -> int: + (user_version,) = connection.execute("PRAGMA user_version").fetchone() return user_version -def migrate(conn: sqlite3.Connection, migrations: list[str]) -> None: - version = get_version(conn) +def migrate(connection: sqlite3.Connection, migrations: list[str]) -> None: + version = get_version(connection) for i in count(version + 1): if i - 1 >= len(migrations): break migration = migrations[i - 1] try: - conn.executescript( + connection.executescript( "BEGIN IMMEDIATE TRANSACTION;\n" f"{migration}\n" f"PRAGMA user_version = {i:d}" ) except: - conn.execute("ROLLBACK TRANSACTION") + connection.execute("ROLLBACK TRANSACTION") raise else: - conn.execute("COMMIT TRANSACTION") + connection.execute("COMMIT TRANSACTION") @contextmanager |