import sqlite3 create = sqlite3.connect("db") connect = create.cursor() # Create TABLE only used once # connect.execute("""CREATE TABLE IPS ( # user_vpn, # user_ips text # )""") 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) # ] # insert 2 values to IPS TABLE # connect.executemany("INSERT INTO IPS VALUES (?,?) ", users) # commit the input to db # 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(): userinput = '10.10.11.1' items = connect.fetchall() for item in items: 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() #close the db create.close()