I am working in python and i am trying to create a database and then a table to populate data everything works but when i try to insert the data in that table it does not populate in table.
Here is my code:
db = MySQLdb.connect(host="localhost", user="root", passwd="123edcde")
c = db.cursor()
c.execute('create database if not exists testMovies')
db.select_db('testMovies')
sql = '''CREATE TABLE `testMovies`.`moviesDB` (
`cinema_id` INT(20) NULL DEFAULT "0" ,
`movie_id` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`added` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`showtime` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`theatre` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`lang` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB;'''
try:
c.execute(sql)
except:
pass
sql = '''INSERT INTO `moviesDB`(`cinema_id`, `movie_id`, `added`, `showtime`, `theatre`, `lang`) VALUES ("1","why is","it","not","working","?")'''
print c.execute(sql)
When i tried to print as well as execute the insert statement, it returns "1", means it was successful but when i try to check the row, i find table stays empty. I have manually tried executing this insert command and it works but i do not know why it is not working with python script in my development ubuntu 14.04 server.