Tuesday, December 25, 2012

#I wrote a simple python program that creates a database with sqlite3 and a GUI with Tkinter. #It won't be useful except as reference for me.

from Tkinter import *
import sqlite3

def makedatabase():
    conn=sqlite3.connect('mydb.db')
    cur=conn.cursor()
    cur.execute("CREATE TABLE IF NOT EXISTS atable(name string, phone string)")
    cur.execute("INSERT INTO atable VALUES('Stephany','123-1234')")
    thedata=cur.execute("SELECT * FROM atable")
    for line in thedata:
        print line[0]
        print line[1]
   
root=Tk()
btn=Button(root,text="Run ",command=makedatabase)
btn.pack()
root.mainloop()




No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.