|
|
|
@ -12,15 +12,21 @@ links = [ |
|
|
|
|
|
|
|
|
|
# SQLite setup |
|
|
|
|
cur = con.cursor() |
|
|
|
|
cur.execute('''CREATE TABLE links ( |
|
|
|
|
url text NOT NULL, |
|
|
|
|
name text NOT NULL, |
|
|
|
|
clicks int NOT NULL, |
|
|
|
|
active int NOT NULL, |
|
|
|
|
position int NOT NULL UNIQUE, |
|
|
|
|
UNIQUE(url, name) |
|
|
|
|
)''') |
|
|
|
|
cur.executemany("INSERT INTO links VALUES (?,?,?,?,?)", links) |
|
|
|
|
con.commit() |
|
|
|
|
|
|
|
|
|
# test if table already exists |
|
|
|
|
cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='links'") |
|
|
|
|
if cur.fetchone(): |
|
|
|
|
print('Links table already exists.') |
|
|
|
|
else: |
|
|
|
|
cur.execute('''CREATE TABLE links ( |
|
|
|
|
url text NOT NULL, |
|
|
|
|
name text NOT NULL, |
|
|
|
|
clicks int NOT NULL, |
|
|
|
|
active int NOT NULL, |
|
|
|
|
position int NOT NULL UNIQUE, |
|
|
|
|
UNIQUE(url, name) |
|
|
|
|
)''') |
|
|
|
|
cur.executemany('INSERT INTO links VALUES (?,?,?,?,?)', links) |
|
|
|
|
con.commit() |
|
|
|
|
|
|
|
|
|
con.close() |