For the life of me I can't figure out why the below module won't add new rows to my DB. I can add them using the command line interface. I can also add them by using other means (ie. writing commands to a script file and using os.system('...'), but if I use cursor.execute(), no rows are added (even though the table is created). Here is a minimal script for your viewing pleasure. Note that I am getting no errors or warnings when I run this script
#!/usr/bin/env python
import MySQLdb
if __name__ == '__main__':
db = MySQLdb.connect ( host="localhost", user="user", passwd="passwd", db="db" )
cursor = db.cursor()
cursor.execute (
"""
CREATE TABLE IF NOT EXISTS god_i_really_hate_this_stupid_library
(
id INT NOT NULL auto_increment,
username VARCHAR(32) NOT NULL UNIQUE,
PRIMARY KEY(id)
) engine=innodb;
"""
)
cursor.execute (
"""
INSERT INTO god_i_really_hate_this_stupid_library
( username )
VALUES
( 'Booberry' );
"""
)
cursor.close()