【发布时间】:2017-04-08 20:06:55
【问题描述】:
我多次尝试解决stackoverflow中其他问题的问题,但均未成功。我现在正在学习python。
我知道如何用 PHP 做,但我需要用 python 做。
我有一张表 dentistas 有 4 列 id、web、email、telefono。
我从另一个文件中导入了一个包含 web url 的列表。
我想在 web 列中插入这些 websurl。
我现在使用的代码在终端中没有显示错误,但没有向表中插入任何内容:
# coding=utf-8
import MySQLdb
from parser import lista
bd = MySQLdb.connect('localhost', 'testuser', 'test123', 'leads') # Connecting to the database
cursor = bd.cursor() # Creating the cursor
for x in lista:
cursor.execute("INSERT INTO dentistas(web) VALUES(%s)", (x,))
【问题讨论】:
标签: python mysql mysql-python