Answer the question
In order to leave comments, you need to log in
Python + MySql: Why is no data being added to the table?
Following code
import MySQLdb
n = 401
conn = MySQLdb.connect(user='root', host='localhost', db='main_database')
cursor = conn.cursor()
for i in range(1, n):
cursor.execute(f'INSERT INTO lessons (id, title, text1, image1, text2, image2) VALUES ({i}, "", "", "", "", "");')
conn.close()
logically should enter 400 records into the database. import MySQLdb
conn = MySQLdb.connect(user='root', host='localhost', db='main_database')
cursor = conn.cursor()
cursor.execute("SELECT * FROM lessons")
row = cursor.fetchone()
print(row)
conn.close()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question