You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
965 B

import sqlite3
import os
DB_PATH = os.path.join(os.path.dirname(__file__), 'links.db')
con = sqlite3.connect(DB_PATH)
# array of links to store
links = [
('','CS Club Website',0,0,1),
# SQLite setup
cur = con.cursor()
# test if table already exists
cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='links'")
if cur.fetchone():
raise Exception('Links table already exists.')
cur.execute('''CREATE TABLE links (
url text NOT NULL,
name text NOT NULL,
clicks int NOT NULL,
position int NOT NULL UNIQUE,
active int NOT NULL,
UNIQUE(url, name)
cur.executemany('INSERT INTO links VALUES (?,?,?,?,?)', links)