29 lines
732 B
Python
29 lines
732 B
Python
import psycopg2
|
|
|
|
conn = psycopg2.connect(
|
|
host="localhost",
|
|
port=5432,
|
|
database="buchhaltung",
|
|
user="postgres",
|
|
password="postgres"
|
|
)
|
|
cursor = conn.cursor()
|
|
|
|
# Pruefe Schema
|
|
cursor.execute("SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'kredit_zahlungen'")
|
|
columns = cursor.fetchall()
|
|
print("Spalten in kredit_zahlungen:")
|
|
for col in columns:
|
|
print(f" {col[0]}: {col[1]}")
|
|
|
|
# Zeige einen Beispiel-Datensatz
|
|
cursor.execute("SELECT * FROM kredit_zahlungen LIMIT 1")
|
|
row = cursor.fetchone()
|
|
print(f"\nBeispiel-Datensatz:")
|
|
for i, col in enumerate(columns):
|
|
if i < len(row):
|
|
print(f" [{i}] {col[0]} = {row[i]} (Typ: {type(row[i])})")
|
|
|
|
cursor.close()
|
|
conn.close()
|