1

I tried many times to solve my problem with other questions in stackoverflow with no success. I'm learning python right now.

I know how to do it in PHP but I need to do it in python.

I have a table dentistas with 4 columns id, web, email, telefono.

And I import from another file with a list containing web urls.

I want to insert those websurls in the web column.

The code that im using right now doesn't shows me an error in the terminal, but doesn't insert anything to the table:

# 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,))
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pablo Barrios
  • 23
  • 1
  • 9

1 Answers1

2

You forgot to commit() and save your current database state.

Try using bd.commit() after the loop.

dot.Py
  • 5,007
  • 5
  • 31
  • 52