Answer the question
In order to leave comments, you need to log in
How to parse data into mySQL table in Python?
Friends, I recently started learning to program in Python...
I'm trying to parse a list of titles of all series from LostFilms into mySQL table.
It turned out to find and display the names, but to push them into the table - no (
from bs4 import BeautifulSoup
import mysql.connector
import unicodedata
data_html = open('LF_all_ser.html',encoding='utf8').read()
soup = BeautifulSoup(data_html, 'html.parser')
All_names = soup.find_all('div', class_='name-ru')
i = 0
for div in All_names:
a = div.get_text()
i = i+1
while i<10:
conn = mysql.connector.connect(user = 'root', password = 'pass', host = 'localhost', database = 'test')
cursor = conn.cursor()
add_ser = 'INSERT INTO allser (id, name) VALUES (%s,%s)'
data_ser = [ (i, a),]
cursor.executemany(add_ser, data_ser)
conn.commit()
Answer the question
In order to leave comments, you need to log in
Try running commands like
ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question