diff options
-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 |