|
|
@ -69,7 +69,8 @@ class Database:
|
|
|
|
if self.check_user_name(user.name) and user.pass_hash is not None:
|
|
|
|
if self.check_user_name(user.name) and user.pass_hash is not None:
|
|
|
|
db = self.connect()
|
|
|
|
db = self.connect()
|
|
|
|
crs = db.cursor()
|
|
|
|
crs = db.cursor()
|
|
|
|
query = "INSERT INTO " + self.USER_TABLE_FILE + "(`name`,`password`)" + \
|
|
|
|
query = "INSERT INTO " + self.USER_TABLE_FILE + \
|
|
|
|
|
|
|
|
"(`name`,`password`)" + \
|
|
|
|
"VALUES (?, ?) ON CONFLICT DO NOTHING"
|
|
|
|
"VALUES (?, ?) ON CONFLICT DO NOTHING"
|
|
|
|
crs.execute(query, (user.name, user.pass_hash))
|
|
|
|
crs.execute(query, (user.name, user.pass_hash))
|
|
|
|
db.commit()
|
|
|
|
db.commit()
|
|
|
@ -82,8 +83,9 @@ class Database:
|
|
|
|
db = self.connect()
|
|
|
|
db = self.connect()
|
|
|
|
crs = db.cursor()
|
|
|
|
crs = db.cursor()
|
|
|
|
reviewed = dt.today().strftime('%Y-%m-%d')
|
|
|
|
reviewed = dt.today().strftime('%Y-%m-%d')
|
|
|
|
query = "INSERT INTO " + self.ENTRY_TABLE_FILE + "(`name`,`date`, `text`, `rating`, `user_id`, `reviewed`)" + \
|
|
|
|
query = "INSERT INTO " + self.ENTRY_TABLE_FILE + \
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?)"
|
|
|
|
"(`name`,`date`, `text`, `rating`, `user_id`, `reviewed`)" + \
|
|
|
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?)"
|
|
|
|
crs.execute(query, (name, date, text, rating, user_id, reviewed))
|
|
|
|
crs.execute(query, (name, date, text, rating, user_id, reviewed))
|
|
|
|
db.commit()
|
|
|
|
db.commit()
|
|
|
|
return crs.lastrowid
|
|
|
|
return crs.lastrowid
|
|
|
@ -125,9 +127,3 @@ class Database:
|
|
|
|
user = User(name, pass_hash)
|
|
|
|
user = User(name, pass_hash)
|
|
|
|
user.set_id(ident)
|
|
|
|
user.set_id(ident)
|
|
|
|
return user
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#db = Database()
|
|
|
|
|
|
|
|
#db.insert_entry("name", "2020", "text", 50, 1)
|
|
|
|
|
|
|
|
#res = db.get_entries()
|
|
|
|
|
|
|
|
# print(res)
|
|
|
|
|
|
|
|