Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:25:44+00:00 2026-05-28T21:25:44+00:00

I am trying to enter values into a mysql db using python. To this

  • 0

I am trying to enter values into a mysql db using python. To this end, I have something like:

import MySQLdb
variables=[]*10 #list of variables.
n=len(variables)

#create python-mysql cursor connection
..
#load values into mysql:
for i in range(0,n):
    cursor.executemany(sql, variables[i])

This shoots out some errors in rows (approx 1% of the rows):

Warning: Incorrect string value: '\xD0\xA2\xD0\xB5\xD0\xBA...' for column 'Link' at row 395
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x91\xD0\xB8\xD1\x82...' for column 'Link' at row 431
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x91\xD0\xB8\xD1\x82...' for column 'Link' at row 568
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\xA7\xD0\xB5\xD0\xBB...' for column 'Link' at row 665
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x96\xD0\xB5\xD0\xBB...' for column 'Link' at row 827
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x9B\xD1\x8E\xD0\xB1...' for column 'Link' at row 1242
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\xA2\xD0\xB0\xD0\xB9...' for column 'Link' at row 1310
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x9B\xD1\x8E\xD0\xB1...' for column 'Link' at row 1468
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x94\xD0\xBD\xD0\xB5...' for column 'Link' at row 1687
cursor.executemany(sql, variables[i])
mergeDB.py:85: Warning: Incorrect string value: '\xD0\x91\xD0\xB5\xD1\x81...' for column 'Link' at row 1848
cursor.executemany(sql, variables[i])

From previous SOF threads, I have tried using inside my python file:

ALTER TABLE dbx.tablex MODIFY Link VARCHAR(255) CHARACTER SET utf8; COLLATE utf8_general_ci NOT NULL;

but this gives me an error:

ALTER TABLE dbx.tablex MODIFY Link VARCHAR(255) CHARACTER SET utf8; COLLATE utf8_general_ci NOT NULL;
          ^
SyntaxError: invalid syntax

How does one solve this problem? How can I simply delete (tell python not to load the rows) the rows which have the “Incorrect String Value?” within this loop:

for i in range(0,n):
    cursor.executemany(sql, variables[i])
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:25:45+00:00Added an answer on May 28, 2026 at 9:25 pm
    ALTER TABLE dbx.tablex MODIFY Link VARCHAR(255) CHARACTER SET utf8; COLLATE utf8_general_ci NOT NULL;
    

    This is a MySQL query, not a Python statement. You need to pass the above to MySQL.

    Also, [] * 10 does not do what you think it does. And the proper way to iterate over a list of variables is:

    for variable in variables:
        cursor.execute(sql, variable)
    

    But you can do this directly:

    cursor.executemany(sql, variables)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem using the MySQLdb library. I'm trying to insert values into
I am trying to inserting value enter in textbox into table like this INSERT
I'm trying to enter edit mode on a specific cell like this: void MainWindow::on_addButton_released()
I am trying to enter the date and time into datetime field in MySql.
I'm trying to insert some data into a local MySQL database by using MySQL
When trying to enter a SQL query with parameters using the Oracle OLE DB
I'm trying to enter a little bit of HTML into an ASP.NET Dynamic Data
I'm trying to capture the ENTER event of a TextInput like so: a_txt.addEventListener(fl.events.ComponentEvent.ENTER, aEnter);
I am trying to integrate the function into a map where you can enter
I am trying to select from a mySQL table using prepared statements. The select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.