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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:05:48+00:00 2026-05-15T22:05:48+00:00

I have a large SQLite database with a mix of text and lots of

  • 0

I have a large SQLite database with a mix of text and lots of other columns var1 … var 50. Most of these are numeric, though some are text based.

I am trying to extract data from the database, process it in python and write it back – I need to do this for all rows in the db.

So far, the below sort of works:

# get row using select and process
fields = (','.join(keys)) # "var1, var2, var3 ... var50"
results = ','.join([results[key] for key in keys]) # "value for var1, ... value for var50"
cur.execute('INSERT OR REPLACE INTO results (id, %s) VALUES (%s, %s);' %(fields, id, results))

This however, nulls the columns that I don’t explicitly add back. I can fix this by re-writing the code, but this feels quite messy, as I would have to surround with quotes using string concatenation and rewrite data that was there to begin with (i.e. the columns I didn’t change).

Apparently the way to run updates on rows is something like this:

update table set var1 = 4, var2 = 5, var3="some text" where id = 666;

Presumably the way for me would be to run map , and add the = signs somehow (not sure how), but how would I quote all of the results appropriately (Since I would have to quote the text fields, and they might contain quotes within them too .. )?

I’m a bit confused. Any pointers would be very helpful.

Thanks!

  • 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-15T22:05:48+00:00Added an answer on May 15, 2026 at 10:05 pm

    As others have stressed, use parametrized arguments. Here is an example of how you might construct the SQL statement when it has a variable number of keys:

    sql=('UPDATE results SET '
         + ', '.join(key+' = ?' for key in keys)
         + 'WHERE id = ?')
    args = [results[key] for key in keys] + [id]
    cur.execute(sql,args)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a local SQLite Database and need to return a large number of
i have large numbers of text files and i am in problem that i
I have large database table, approximately 5GB, now I wan to getCurrentSnapshot of Database
I have a fairly large SQL Server database; I'd like to pull 4 tables
I have a SQLite database with with just over 6,000 rows of addresses in
I have a large amount of data i want to import into one sqlite
I have recently inherited a large project using an sqlite3 database and currently I
I have an sqlite database with over 400k records. I have just found that
I have a listview which loads its data from sqlite database. Each row in
I have a web application working with sqlite database. My version of sqlite is

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.