From b501b61569402374339d20af2fda95c537f99840 Mon Sep 17 00:00:00 2001
From: anima
Date: Sun, 9 May 2021 22:12:16 +0200
Subject: [PATCH] add user handling
---
timeTrack.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 3 deletions(-)
diff --git a/timeTrack.py b/timeTrack.py
index 6628837..bda91e0 100644
--- a/timeTrack.py
+++ b/timeTrack.py
@@ -113,12 +113,26 @@ class TimeTrack:
connect = sqlite3.connect(self.DATABASE)
cursor = connect.cursor()
##> vorgang optimieren...
+ ##> prüfung if DATA list
+ ##> prüfung if init SQL list
for sql in SQL:
try:
if isinstance(sql, list):
- cursor.executemany(sql, DATA)
+ logging.debug('SQL is list')
+ if DATA == '':
+ logging.info('Many execute without data')
+ cursor.executemany(sql)
+ else:
+ logging.info('Many execute with data')
+ cursor.executemany(sql, DATA)
else:
- cursor.execute(sql)
+ logging.debug('SQL is not list ')
+ if DATA == '':
+ logging.info('single execute without data')
+ cursor.execute(sql)
+ else:
+ logging.info('single execute with data')
+ cursor.execute(sql, DATA)
except:
logging.error('Fehler beim schreiben in DB')
logging.debug(sql)
@@ -129,8 +143,41 @@ class TimeTrack:
pass
connect.close()
+ def create_user(self):
+ data = []
+ sql = []
+ data.append(input('Enter your Name: '))
+ sql.append("""
+ INSERT INTO users (
+ name
+ ) values (
+ ?
+ )
+ """)
+ self.db_connect(sql, data)
+ pass
+
+ ##> verbugt noch nicht funktional
+ def get_users(self, UID=0):
+ data = []
+ data.append(input('User ID: '))
+ if UID == 0:
+ sql = [
+ """
+ SELET id, name FROM users
+ """
+ ]
+ else:
+ sql = [
+ """
+ SELET id, name FROM users WHERE id=?
+ """
+ ]
+ self.db_connect(sql)
+
def set_user(self):
pass
-test = TimeTrack()
\ No newline at end of file
+test = TimeTrack()
+test.get_users()
\ No newline at end of file