I'm trying to figure out how to use the MySQLdb library in python (I am novice at best for both of them).
I'm following the code here: http://www.kitebird.com/articles/pydbapi.html
Specifically:
cursor = conn.cursor ()
cursor.execute ("DROP TABLE IF EXISTS animal")
cursor.execute ("""
CREATE TABLE animal
(
name CHAR(40),
category CHAR(40)
)
""")
cursor.execute ("""
INSERT INTO animal (name, category)
VALUES
('snake', 'reptile'),
('frog', 'amphibian'),
('tuna', 'fish'),
('racoon', 'mammal')
""")
print "Number of rows inserted: %d" % cursor.rowcount
cursor.close ()
conn.close ()
I have poked around it, and can get it to create tables or drop tables by changing the basic code, but I can't get it to actually commit the INSERT. It returns the row.count value as expected (even when I change the value table, it changes to what I expect it to be).
Everytime I look into the db (via PHPMyAdmin) there are no inserts made.
Can anyone point me in the right direction?