Skip to content

Instantly share code, notes, and snippets.

@stefanmonkey
Created January 8, 2014 07:05
Show Gist options
  • Save stefanmonkey/8312916 to your computer and use it in GitHub Desktop.
Save stefanmonkey/8312916 to your computer and use it in GitHub Desktop.
table
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb as mdb
con = mdb.connect('localhost', 'testuser', '123456', 'testdb');
with con:
cur = con.cursor()
cur.execute("DROP TABLE IF EXISTS Writers")
cur.execute("CREATE TABLE Writers(Id INT PRIMARY KEY AUTO_INCREMENT, \
Name VARCHAR(25))")
cur.execute("INSERT INTO Writers(Name) VALUES('Jack London')")
cur.execute("INSERT INTO Writers(Name) VALUES('Honore de Balzac')")
cur.execute("INSERT INTO Writers(Name) VALUES('Lion Feuchtwanger')")
cur.execute("INSERT INTO Writers(Name) VALUES('Emile Zola')")
cur.execute("INSERT INTO Writers(Name) VALUES('Truman Capote')")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment