chore: automatic commit 2025-04-30 12:48
This commit is contained in:
34
check_schema.py
Normal file
34
check_schema.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sqlite3
|
||||
|
||||
# Verbindung zur Datenbank herstellen
|
||||
conn = sqlite3.connect('systades.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Liste aller Tabellen abrufen
|
||||
print("Alle Tabellen in der Datenbank:")
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||||
tables = cursor.fetchall()
|
||||
for table in tables:
|
||||
print(f"- {table[0]}")
|
||||
|
||||
# Schema der Datenbank abrufen
|
||||
cursor.execute("SELECT sql FROM sqlite_master WHERE type='table';")
|
||||
schemas = cursor.fetchall()
|
||||
|
||||
# Schematische Informationen ausgeben
|
||||
print("\nDatenbankschema:")
|
||||
for schema in schemas:
|
||||
print("\n" + str(schema[0]))
|
||||
|
||||
# Schema der User-Tabelle genauer untersuchen, falls vorhanden
|
||||
if ('user',) in tables:
|
||||
print("\n\nBenutzer-Tabellenschema:")
|
||||
cursor.execute("PRAGMA table_info(user);")
|
||||
user_columns = cursor.fetchall()
|
||||
for column in user_columns:
|
||||
print(f"Column: {column[1]}, Type: {column[2]}, NOT NULL: {column[3]}, Default: {column[4]}, Primary Key: {column[5]}")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user