1
我嘗試了很多次,以解決我的問題與其他問題在stackoverflow沒有成功。我正在學python。插入到MySQL的Python列表
我知道如何在PHP中做到這一點,但我需要在python中做到這一點。
我有一個表dentistas
與4列ID,網絡,電子郵件,telefono。
然後我從另一個包含網址的列表導入文件。
我想將這些websurls插入到web列中。
,即時通訊使用的是現在不顯示我在終端的錯誤,但不插入任何表中的代碼:
# 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,))
謝謝你,是提交();) –
忘了以前的答案....你在你的數據庫中進行更改後,compose? –
100%的轉機哈哈,但你是對的!看到這個http://stackoverflow.com/questions/2847999/why-the-need-to-commit-explicitly-when-doing-an-update問題爲什麼你必須提交更改數據庫的遊標執行。 – datell