Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- conn = sqlite3.connect("phenvar.db")
- def createTables(conn):
- c = conn.cursor()
- c.execute('''CREATE TABLE IF NOT EXISTS publications (id INTEGER PRIMARY KEY, title TEXT, abstract TEXT, FOREIGN KEY (id) REFERENCES snps (rsid))''')
- c.execute('''CREATE TABLE IF NOT EXISTS snps (rsid INTEGER PRIMARY KEY, publication_id INTEGER, FOREIGN KEY (publication_id) REFERENCES publications (id))''')
- def addSnpsRow(conn, rsid, publication_id):
- c = conn.cursor()
- c.execute("INSERT INTO snps VALUES (?, ?)", (rsid, publication_id))
- def addPublicationsRow(conn, id, title, abstract):
- c = conn.cursor()
- c.execute("INSERT INTO publications VALUES (?, ?, ?)", (id, title, abstract))
- createTables(conn)
- #addSnpsRow(conn, 1234, 9000)
- #addPublicationsRow(conn, 9000, "Jon farts a lot", "In this paper we examine just what went wrong in Jon's ass to cause such a problematic existence.")
- addSnpsRow(conn, 2222, 2)
- addSnpsRow(conn, 3333, 3)
- addSnpsRow(conn, 4444, 4)
- addSnpsRow(conn, 5555, 5)
- addPublicationsRow(conn, 2, "title2", "abstract2")
- addPublicationsRow(conn, 3, "title3", "abstract3")
- addPublicationsRow(conn, 4, "title4", "abstract4")
- addPublicationsRow(conn, 5, "title5", "abstract5")
- conn.commit()
- conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement