sync util scripts

This commit is contained in:
linguini
2026-07-31 01:41:46 +02:00
parent 588fa6f62b
commit 21c7fde12d
4 changed files with 580 additions and 0 deletions
@@ -0,0 +1,38 @@
import sqlite3
db = "paintingzz.db"
conn = sqlite3.connect(db)
cur = conn.cursor()
table = "inspections"
# Find completely NULL columns
cur.execute(f"PRAGMA table_info({table})")
columns = [row[1] for row in cur.fetchall()]
empty_columns = []
for col in columns:
print('cucurucu')
cur.execute(
f'SELECT COUNT(*) FROM "{table}" WHERE "{col}" IS NOT NULL'
)
count = cur.fetchone()[0]
if count <100 :
print('list b growing')
empty_columns.append(col)
print(empty_columns)
print("Removing:", empty_columns)
# SQLite >= 3.35 supports DROP COLUMN
for col in empty_columns:
cur.execute(
f'ALTER TABLE "{table}" DROP COLUMN "{col}"'
)
conn.commit()
conn.close()