Spaces:
Paused
Paused
BPEL Bot commited on
Commit ·
fc43080
1
Parent(s): 04721a8
scripts: skip missing tables in db check
Browse files
scripts/check_db_connectivity.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
from __future__ import annotations
|
| 3 |
|
| 4 |
import os
|
| 5 |
-
from sqlalchemy import create_engine, text
|
| 6 |
|
| 7 |
TABLES_TO_CHECK = [
|
| 8 |
"otree_session",
|
|
@@ -22,7 +22,11 @@ def main() -> int:
|
|
| 22 |
try:
|
| 23 |
with engine.connect() as conn:
|
| 24 |
print(f"[db-debug] Connected; dialect={conn.dialect.name}")
|
|
|
|
| 25 |
for table in TABLES_TO_CHECK:
|
|
|
|
|
|
|
|
|
|
| 26 |
try:
|
| 27 |
count = conn.execute(text(f"SELECT COUNT(*) FROM {table}")).scalar()
|
| 28 |
print(f"[db-debug] {table}: {count}")
|
|
|
|
| 2 |
from __future__ import annotations
|
| 3 |
|
| 4 |
import os
|
| 5 |
+
from sqlalchemy import create_engine, inspect, text
|
| 6 |
|
| 7 |
TABLES_TO_CHECK = [
|
| 8 |
"otree_session",
|
|
|
|
| 22 |
try:
|
| 23 |
with engine.connect() as conn:
|
| 24 |
print(f"[db-debug] Connected; dialect={conn.dialect.name}")
|
| 25 |
+
inspector = inspect(conn)
|
| 26 |
for table in TABLES_TO_CHECK:
|
| 27 |
+
if not inspector.has_table(table):
|
| 28 |
+
print(f"[db-debug] {table}: missing (skipping)")
|
| 29 |
+
continue
|
| 30 |
try:
|
| 31 |
count = conn.execute(text(f"SELECT COUNT(*) FROM {table}")).scalar()
|
| 32 |
print(f"[db-debug] {table}: {count}")
|