-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdatabase_mod.py
21 lines (19 loc) · 891 Bytes
/
database_mod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import credentials
import pyodbc
def create_table1():
conn = pyodbc.connect('DRIVER='+credentials.driver+';SERVER='+credentials.server
+';DATABASE='+credentials.database+';UID='+credentials.username+';PWD='+credentials.password)
cur = conn.cursor()
if cur.tables(table='TimesNoted', tableType='TABLE').fetchone():
print("",end= "") # exists
else:
cur.execute("CREATE TABLE TimesNoted(id int NOT NULL IDENTITY(1,1) primary key, entry_time varchar(100), exit_time varchar(100))" )
conn.commit()
conn.close()
def insert_data1(Entry_Time, Exit_Time):
conn = pyodbc.connect('DRIVER='+credentials.driver+';SERVER='+credentials.server
+';DATABASE='+credentials.database+';UID='+credentials.username+';PWD='+credentials.password)
cur = conn.cursor()
cur.execute("INSERT INTO TimesNoted(entry_time,exit_time) VALUES (?, ?)", (Entry_Time, Exit_Time))
conn.commit()
conn.close()