initial 1312 funktioniert ein bisschen

This commit is contained in:
2025-12-13 12:21:44 +01:00
commit 59dd267659
29 changed files with 973 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import sqlite3
from flask import render_template
from __main__ import app
@app.route("/database")
def database():
con = sqlite3.connect("kver.db")
cursor = con.cursor()
# cursor.execute("INSERT INTO movie VALUES (?, ?, ?)", ("Erster Film", 1900, 8.2))
# con.commit()
res = cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
return render_template("database.html", tables=res.fetchall())
# !!! USER VALUE IN SQL STATEMENT !!!
@app.route("/database/<table>")
def db_table(table):
con = sqlite3.connect("kver.db")
cursor = con.cursor()
# cursor.execute("INSERT INTO movie VALUES (?, ?, ?)", ("Erster Film", 1900, 8.2))
# con.commit()
# columns = cursor.execute("SELECT sql FROM sqlite_master WHERE type='table' AND name=?;", [table])
# !!! USER VALUE IN SQL-STATEMENT !!!
data = cursor.execute(f"SELECT * FROM {table};")
return render_template("database_table.html", data=data.fetchall())