From e59fec22a758b79bd48d6e8527ff7ffc9b66a9cd Mon Sep 17 00:00:00 2001 From: leon Date: Thu, 29 Dec 2022 06:13:03 +0000 Subject: [PATCH] add checking but not complete --- data.py | 35 +++++++++++++++++++++-------------- db | Bin 8192 -> 8192 bytes 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/data.py b/data.py index 5948c6c..af9782f 100644 --- a/data.py +++ b/data.py @@ -2,6 +2,7 @@ import sqlite3 create = sqlite3.connect("db") connect = create.cursor() +# Create TABLE only used once # connect.execute("""CREATE TABLE IPS ( # user_vpn, # user_ips text @@ -9,25 +10,31 @@ connect = create.cursor() def insert_ips(): #user input - user_name = input(str("username: ")) - user_ips = input(str("ip: ")) - #add input to list inside tuple - users = [ - (user_name,user_ips) - ] + # user_name = input(str("username: ")) + # user_ips = input(str("ip: ")) + # #add input to list inside tuple + # users = [ + # (user_name,user_ips) + # ] # insert 2 values to IPS TABLE - connect.executemany("INSERT INTO IPS VALUES (?,?) ", users) + # connect.executemany("INSERT INTO IPS VALUES (?,?) ", users) # commit the input to db - create.commit() - # read db - connect.execute("SELECT * FROM IPS") - + # create.commit() + # read db with row id + connect.execute("SELECT rowid, * FROM IPS") #to check with rowid use WHERE rowid = 1 #close the db def checking(): - items = connect.fetchall() + userinput = '10.10.11.1' + items = connect.fetchall() for item in items: - print(item[1]) - + item_list = [item[2]] + print(item_list) + # if item_list == userinput: + # print('ip exist') + # break + # else: + # print('new ip') + # break #call the func insert_ips() checking() diff --git a/db b/db index 0575a4ef1b86847984d48f574eb22176d539d022..0218da91f4911adb185d90856af7cf6167371997 100644 GIT binary patch delta 228 zcmZp0XmFSy%_uxk#+gxgW5N=C4I#d*4E%5TZ}Xqv-@?C;zmLC~KZ8G%--%y?Uxc57 z?+4#AzH@ws__l5=?BuKG7Gf3^Elx>HODs-F;}T>R6^3xq!~~cX<