-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
27 lines (21 loc) · 780 Bytes
/
database.py
File metadata and controls
27 lines (21 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sqlite3
from encoder import *
def create_database():
database = sqlite3.connect("INFO.db")
database.execute('''CREATE TABLE IO
(address TEXT PRIMARY KEY NOT NULL,
password TEXT NOT NULL)''')
database.commit()
database.close()
def write_to_database(address, password):
password = encode(password)
address = encode(address)
database = sqlite3.connect("INFO.db")
database.execute("INSERT INTO IO(address,password) VALUES('"+address+"', '"+password+"')")
database.commit()
database.close()
def read_from_database():
database = sqlite3.connect("INFO.db")
search = database.execute("SELECT address, password from IO").fetchall()
database.close()
return [decode(search[0][0]), decode(search[0][1])]