Friday, 15 June 2012

Python MySQLdb not inserting data -



Python MySQLdb not inserting data -

ubuntu version: 12.10 mysql server version: 5.5.29-0 python version: 2.7

i trying utilize mysqldb insert info localhost mysql server. don't errors when run script info isn't come in table. view tables phpmyadmin.

i tried going basics , next tutorial same result. weird thing can create , delete tables not come in data.

the code tutorial reports 4 rows inserted. preventing info beingness entered table when script reports fine??

cursor = conn.cursor () cursor.execute ("drop table if exists animal") cursor.execute (""" create table animal ( name char(40), category char(40) ) """) cursor.execute (""" insert animal (name, category) values ('snake', 'reptile'), ('frog', 'amphibian'), ('tuna', 'fish'), ('racoon', 'mammal') """) print "%d rows inserted" % cursor.rowcount

add :

conn.commit()

after bottom of script.

on side note, have @ next : http://mysql-python.sourceforge.net/mysqldb.html

python-2.7 mysql-python ubuntu-12.10

No comments:

Post a Comment