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

  • SEARCH
  • Home
  • 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 8225775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:31:45+00:00 2026-06-07T15:31:45+00:00

The problem is with inserting json strings into MySQL database. In my python program

  • 0

The problem is with inserting json strings into MySQL database.
In my python program I obtain json as a result of json.dumps(d) where d is a dictionary. Inserting code is:

        query = ("INSERT INTO bm_triesJsons VALUES (%s, %s, %s);"%
                 (article_id, revision_number, jsn))
        print query
        cur.execute(query)

It looks like the problem is quotes, there is no escape symbol in front of quotes.
How can I fix this?

  • 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-06-07T15:31:48+00:00Added an answer on June 7, 2026 at 3:31 pm

    Use the parameterized approach to values when doing a query. The driver will handle escapes:

    query = "INSERT INTO bm_triesJsons VALUES (%s, %s, %s);"
    cur.execute(query, (article_id, revision_number, jsn))
    

    If you want direct and manual access to the escape function MySQLdb uses, you can do it like this:

    c = MySQLdb.connection()
    print c.escape_string('{"foo":"bar"}')
    # {\"foo\":\"bar\"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem in inserting the listbox value into mysql database in vb
i have a problem in inserting the listbox value into mysql database in vb
I'm experiencing a problem inserting values into a SQLite database. The data I download
I'm running into a problem inserting rows from a file with 13,000 rows into
I get an error when trying to insert into TABLE_EVENTS but no problem inserting/querying
I have a problem inserting the values from checkboxes in an html document into
Hi i am having problem inserting data into multiple table from one view. First
I have a program that reads financial data in JSON and inserts it into
I got problem inserting the string AM/PM to my mySQL table $timeFormat = mysql_real_escape_string($_POST['timeFormat']);
i have a problem while inserting the date format like mm/dd/yyyy in mySQL. It

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.