Fetched users with python
This commit is contained in:
0
backend/db/__init__.py
Normal file
0
backend/db/__init__.py
Normal file
BIN
backend/db/attendance.db
Normal file
BIN
backend/db/attendance.db
Normal file
Binary file not shown.
11
backend/db/db.py
Normal file
11
backend/db/db.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# This file is for database connection
|
||||
import sqlite3
|
||||
|
||||
# Create the connection once, reuse it
|
||||
# Check same thread is false, because we fast api runs on multiple threads
|
||||
conn = sqlite3.connect("db/attendance.db", check_same_thread=False)
|
||||
conn.row_factory = sqlite3.Row
|
||||
|
||||
def get_db():
|
||||
return conn
|
||||
|
||||
9
backend/db/users.py
Normal file
9
backend/db/users.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# This file is for database functions
|
||||
from db.db import get_db
|
||||
|
||||
def get_users():
|
||||
conn = get_db()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM Employees")
|
||||
users = cursor.fetchall()
|
||||
return users
|
||||
Reference in New Issue
Block a user