Add database functions
This commit is contained in:
BIN
app/app_db/app.db
Normal file
BIN
app/app_db/app.db
Normal file
Binary file not shown.
17
app/app_db/app_db.py
Normal file
17
app/app_db/app_db.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
import pandas as pd
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
# DB_PATH = BASE_DIR / "app_db" / "app.db"
|
||||
DB_PATH = BASE_DIR / "app.db"
|
||||
|
||||
def get_conn():
|
||||
# check_same_thread=False, damit Streamlit mehrere Threads nutzen kann
|
||||
return sqlite3.connect(DB_PATH, check_same_thread=False)
|
||||
|
||||
def get_list(sql, params=None):
|
||||
conn = get_conn()
|
||||
df = pd.read_sql_query(sql, conn, params=params)
|
||||
conn.close()
|
||||
return df
|
||||
Reference in New Issue
Block a user