mysql - my python code write in a temporary data base -
i wrote python code write/read data in/from mysql db. problem table still empty after write in it. , when close program loose data. how created tables:
cursor.execute("create table if not exists employees (id int unsigned not null auto_increment,name varchar(20) not null,lastname varchar(20) not null,post varchar(20) not null,rasid smallint unsigned not null,primary key (id)) engine=innodb;") this how insert data in tables:
cursor.execute("insert employees values (null, %s, %s, %s, %s);",(username, userlastname, userpost, int(data['rasid']))) and how select data tables:
cursor.execute("select * employees name= %s;",(jmsg['face'],)) this after inserting data in table , program still running:
mysql> select * employees; empty set (0.00 sec) nb: can select data after inserting when program still running mentioned table empty. so, code write in temporary table or what?
try
connection.commit() mysql connector/python, you're using here, not autocommit means have manually "push" changes database.
you may want commit after every execute may try run conserve bandwidth (but risk lose changes when went wrong).
Comments
Post a Comment