TypeError:在字符串格式化过程中并非所有参数都被转换[MySQL DB连接]

时间:2015-10-20 08:03:30

标签: python

hostname = raw_input("Enter hostname : ")

connection = MySQLdb.connect (host = "localhost", user = "hawkhost_databas", passwd = "}MFkdDI6]#QX", db = "hawkhost_database")

cursor = connection.cursor ()

cursor.execute ("select User, Hostname, Password, Port from dbinfo where hostname=%s", (hostname))

1 个答案:

答案 0 :(得分:-1)

cursor.execute(“从dbinfo中选择用户,主机名,密码,端口,其中Hostname ='%s'”%d)

这解决了问题