fix =/n in database keys

This commit is contained in:
Leon Vita 2022-12-31 15:02:40 +00:00
parent 225192b371
commit 749317fa04
1 changed files with 9 additions and 9 deletions

18
data.py
View File

@ -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)
#-----------------------------------------------------