I am trying to figure out how to use the MySQLdb library in Python (I start at best for both of them).
I follow the code here in particular:
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 can modify this code to create or delete tables, but I cannot get it to actually perform an INSERT
. It returns the value of row.count
, as expected (even when I change the value in the table, it changes to what I expect).
Every time I browse the database using PHPMyAdmin, no inserts are created. How to pass INSERT
to the database?
source share