config db
This commit is contained in:
parent
5079bf66cc
commit
065d0f23bb
42
data.py
42
data.py
|
@ -2,19 +2,35 @@ import sqlite3
|
|||
|
||||
create = sqlite3.connect("db")
|
||||
connect = create.cursor()
|
||||
connect.execute(""" CREATE TABLE IPS
|
||||
(
|
||||
ips text
|
||||
)
|
||||
""")
|
||||
connect.execute(""" CREATE TABLE USERS
|
||||
(
|
||||
users text
|
||||
)
|
||||
""")
|
||||
# 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
|
||||
connect.execute("SELECT * FROM IPS")
|
||||
|
||||
create.commit()
|
||||
#close the db
|
||||
def checking():
|
||||
items = connect.fetchall()
|
||||
for item in items:
|
||||
print(item[1])
|
||||
|
||||
#call the func
|
||||
insert_ips()
|
||||
checking()
|
||||
|
||||
#close the db
|
||||
create.close()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue