嗨,我在将信息插入数据库时遇到问题。它不会发出错误。代码在这里。
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()
在我运行Room("roomname")
它应该输出但实际上没有任何东西进入数据库之后