python MySQLdb wont insert into db
Question: Hi I have an issue with inserting info to my db. It doesn't give off an
error.The code is here.

    
    
    import MySQLdb as m
    
    def Room(room):
       db = m.connect("localhost","root","password","rooms")
       cur = db.cursor()
       cur.execute('INSERT INTO rooms (name) VALUES("%s");'% (room))
    def getRoomDb():
       db = m.connect("localhost","root","password","rooms")
       cur = db.cursor()
       cur.execute("SELECT * FROM rooms;")
       result = cur.fetchall()
       return result
    
    print getRoomDb()
    

after i run the `Room("roomname")` it outputs like it should but nothing
actually gets put into the db


Answer: You didn't call `commit()` for the transaction in which you executed the
INSERT.

In Python, the default action is to roll back work, unless you explicitly
commit.

See also:

  * [Python MySQL - SELECTs work but not DELETEs?](http://stackoverflow.com/questions/1451782/python-mysql-selects-work-but-not-deletes/)
  * [Python MySQLdb update query fails](http://stackoverflow.com/questions/1028671/python-mysqldb-update-query-fails)
  * <http://mysql-python.sourceforge.net/FAQ.html#my-data-disappeared-or-won-t-go-away>

