-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdates.py
More file actions
29 lines (26 loc) · 1 KB
/
Copy pathupdates.py
File metadata and controls
29 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from sqlalchemy import text
class Updates:
def __init__(self, engine):
self.engine = engine
def do_updates(self) -> None:
stmts = [
text("ALTER TABLE named_file ADD COLUMN template varchar(250)"),
text("ALTER TABLE named_paths ADD COLUMN template varchar(250)")
#
# more updates if there are ever any go here
#
]
for s in stmts:
try:
print(f"doing an update to the database: {s}")
with self.engine.connect() as connection:
connection.execute(s)
connection.commit()
except Exception as e:
...
print(f"error: {type(e)}: {e}")
#
# this is expected. we try all the updates every time we think
# we need to update, so most of them can be expected to fail because
# they will have already been applied at an earlier time.
#