Я храню в базе данных MySQL ссылки, но при работе с ними получаю следующую ошибку:
1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'https://www.adidas.com/us/confirmed, https://tidd.ly/3rQ7bwn, https://bit.ly/30G' at line 2
Сам код:
def create_connection_mysql_db(db_host, user_name, user_password, db_name = None):
connection_db = None
try:
connection_db = mysql.connector.connect(
host = db_host,
user = user_name,
passwd = user_password,
database = db_name
)
except Error as db_connection_error:
print("Возникла ошибка: ", db_connection_error)
return connection_db
try:
b=1 #Например
print(len(links.split(', ')))
g=len(links.split(', '))//2
conn = create_connection_mysql_db('***',
'***',
'***',
"heroku_***")
cursor = conn.cursor()
cursor.execute('''
UPDATE links
SET link = '%s'
WHERE id = '%s';''',(', '.join(links.split(', ')[:g]), str(b)))
conn.commit()
cursor.execute('''
UPDATE links
SET link = '%s'
WHERE id = '%s';''',(', '.join(links.split(', ')[g:]),str(b)+str(b)))
conn.commit()
except Error as error:
print(error)
finally:
cursor.close()
conn.close()
Не понимаю что не так