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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:17:32+00:00 2026-06-03T05:17:32+00:00

How would I update an entry that is already in a database using sqlite3?

  • 0

How would I update an entry that is already in a database using sqlite3?

I’ve tried:

db_curs.execute("INSERT INTO `database` (cID) VALUES ('Updated')")

But this, of course, creates a new entry. I can obtain the (line(?)) number (of the entry) and what is the command to update the database rather than create a new entry?

EDIT:

Put a bit better, when I convert the SQL entry to a python list I get the following,

(1, u'GGS-04', u'John', u'Smith', 9, u'0')

I need to be able to add a digit to the last item. Here is what I have.

info = (1, u'GGS-04', u'John', u'Smith', 9, u'0')

for result in info:
    ln           = str(result[0])
    ggs          = str(result[1])
    first_name   = str(result[2])
    last_name    = str(result[3])
    dob          = str(result[4])
    spend        = str(result[5])
while True:
    res = raw_input("Enter points to add: ")
    try:
        int(res)
        break
    except:
        print "Please enter a number..."
        pass
spend = str(int(spend) + int(res))
db_curs.execute("UPDATE `" + db_name + "` (cID, first_name, last_name, date_of_birth, spend) VALUES ('" + srce + "', '" + first_name + "', '" + last_name + "', '" + dob + "' WHERE '" + spend + "')")
db_connection.commit()

Could someone please explain the correct syntax for this command? It would be awesome if I could just update the “Spend” column than having to update them all from prefixed variables.
Thank you 🙂

  • 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-03T05:17:33+00:00Added an answer on June 3, 2026 at 5:17 am

    This shall work:

    db_curs.execute("UPDATE database SET spend =`" + spend + "` WHERE cID="+ cID)
    

    See also SQL Update Syntax

    Btw, “database” isn’t a useful name for a database’s table. What about “users” or “spendtime” or sth more descriptive?

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

Sidebar

Related Questions

I need to insert new records into an Access database. I'm using Visual Studio
I would like to update 3 rows of a single table, with different values
Essentially, I would like to create a database structure that allows for classifying an
My database schema has a 'locked' setting meaning that the entry can not be
How would you update a list by removing the first item? consider the following
This may be an oxymoron, but how would one update a data entity in
I would like to update a Windows Forms application to provide the following features:
I would like to update a large number of C++ source files with an
I would like to update a dll for a server process without stopping the
I would like to update (change the content) some part of the webpage without

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.