【发布时间】:2016-04-22 16:04:14
【问题描述】:
我正在尝试使用字符串和订单号将 id 添加到我的表中。代码如下:
import pymysql.cursors
conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='xxx', db='python')
with conn.cursor() as cursor:
# Create a new record
sql = "INSERT INTO `arzugulgundogdu2` (`id`) VALUES ('dgNotListesi_txtGelisimDurumu_'%s)"
y = int("0")
while y < 10:
cursor.execute(sql, (y))
y = y+1
conn.commit()
另外,当我为 y 选择一个常量值以进行 while 循环时,它看起来像 dgNotListesi_txtGelisimDurumu_'myconstanthere。 为什么字符串和我的 y 变量之间有一个 ' 签名? 谢谢。我对python很陌生:)
【问题讨论】:
标签: python mysql string int pymysql