· 9 years ago · Feb 05, 2017, 08:08 AM
1import sqlite3
2
3
4def create_table():
5 con = sqlite3.connect('links.db')
6 #
7 con.execute('''
8 CREATE TABLE IF NOT EXISTS LINKS
9 (
10 USERNAME TEXT NOT NULL,
11 LINK TEXT NOT NULL
12 )
13 ''')
14 con.close()
15
16
17def update_links_db(username, link):
18 con = sqlite3.connect('links.db')
19 cur = con.cursor()
20 cur.execute("INSERT INTO LINKS VALUES ('{0}','{1}')".format(username, link))
21 print('Insertion has been done successfully')
22 con.close()