From 749317fa04bc4a1a0a5c6e663aeb7928b0540256 Mon Sep 17 00:00:00 2001 From: leon Date: Sat, 31 Dec 2022 15:02:40 +0000 Subject: [PATCH] fix =/n in database keys --- data.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data.py b/data.py index cd34a13..d478bbf 100644 --- a/data.py +++ b/data.py @@ -3,7 +3,7 @@ import subprocess from datetime import datetime #initialize database -create = sqlite3.connect("db") +create = sqlite3.connect("database.db") connect = create.cursor() #Create TABLE only IF NOT Exist @@ -30,7 +30,6 @@ def user_input(): #read keys file with open("publickey.txt","r") as pk: public = pk.read() - print(type(public)) with open("privatekey.txt","r") as prk: private = prk.read() # user input @@ -61,23 +60,24 @@ def add_ips( #insert values to VPN TABLE connect.execute("INSERT INTO VPN VALUES (?,?,?,?,?,?)", ( - ('User = ' + user_name), + (user_name), (user_ips + "/24"), - (user_public_key), - (user_private_key), + ('Public_key= ' + user_public_key.replace('\n', '')), #replace char \n to normal key + ('Private_key' + user_private_key.replace('\n', '')), #replace char \n to normal key ('Date: ' + date), ('Time: ' + time) )) + #Commit into db create.commit() #delete the keys subprocess.run("rm privatekey.txt publickey.txt",shell=True) #should deltet after finish - # connect.execute("SELECT rowid, * FROM VPN") #to check with rowid use WHERE rowid = 1 - # items = connect.fetchall() - # for item in items: - # print(item) + connect.execute("SELECT rowid, * FROM VPN") #search + items = connect.fetchall() + for item in items: + print(item) #-----------------------------------------------------