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 8224009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:54:30+00:00 2026-06-07T14:54:30+00:00

I’m having trouble finding any information on how to do error checking on MySQLdb.

  • 0

I’m having trouble finding any information on how to do error checking on MySQLdb. I have been trying to do a simple update command for a MySQL database and it simply is not working. No matter how I change the terms, or the type of variables I submit to it.

Here are some of my (commented out) attempts:

timeid = twitseek['max_id']
            #timeup = "UPDATE `timeid` set `timestamp`='" + str(timeid) + "';"
            #print timeup
            #c.execute(timeup)

            #timeup = "UPDATE timeid SET timestamp=\"" + str(timeid) + "\"";
            #timeup = "UPDATE timeid set timestamp = '500';"
            timeup = 500
            c.execute("""UPDATE timeid SET timestamp = %d;""", timeup)
            #c.execute(timeup)

All I want to do is upload the value of timeid to the timestamp column’s first value (or any value) in the table timeid.

Nothing I do seems to work and I’ve been sitting here for literally hours trying countless iterations.

  • 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-07T14:54:32+00:00Added an answer on June 7, 2026 at 2:54 pm

    You seem to be missing an obligatory call to .commit() on your connection object to commit your change.

    # Your cursor is c
    # We don't see your connection object, but assuming it is conn...
    c.execute("""UPDATE timeid SET timestamp = %d;""", timeup)
    conn.commit()
    

    The above method will produce valid SQL, but you don’t get the security benefit of prepared statements this way. The proper method to pass in parameters is to use %s, and pass in a tuple of parameters:

    c.execute("UPDATE timeid SET timestamp = %s;", (timeup,))
    conn.commit()
    

    From the MySQLdb FAQ:

    Starting with 1.2.0, MySQLdb disables autocommit by default, as
    required by the DB-API standard (PEP-249). If you are using InnoDB
    tables or some other type of transactional table type, you’ll need to
    do connection.commit() before closing the connection, or else none of
    your changes will be written to the database.

    Conversely, you can also use connection.rollback() to throw away any
    changes you’ve made since the last commit.

    As far as error checking goes, a failed connection or a syntactically invalid query will throw an exception. So you would want to wrap it in a try/except as is common in Python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.