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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:25:35+00:00 2026-06-14T03:25:35+00:00

this method should update a table, but i get a operational sql error at

  • 0

this method should update a table, but i get a operational sql error at the last line:

def update_lookup(table, lookup_table, anon_table, fieldname, anon_field_prefix):

    c.execute('SELECT DISTINCT ' + fieldname + ' FROM ' + table)
    result = c.fetchall() #gives a list of tuples

    #get a list of random integers in range, as many as there are unique mssi's
    rnds = random.sample(xrange(10000,80000),len(result))

    #for every name insert the value in the vesselname lookup
    lst = []
    lst_rev = []
    for i,row in enumerate(result):
        field_value_anon = anon_field_prefix + str(rnds[i]) #create a random mssi number
        field_value = row[0]
        lst_rev.append((anon_table, fieldname , field_value_anon, fieldname, field_value)) #needed later on
        lst.append((field_value, field_value_anon))


    c.executemany('INSERT INTO '+ lookup_table +' VALUES (null, ?, ?)', lst)

    #update the anon table col:

    c.executemany('UPDATE ? SET ?=? WHERE ?=?', lst_rev) //error is trhown

stacktrace:

Traceback (most recent call last):
  File "C:\Users\jgoddijn\workspace\DataAnonDMVV\src\Main.py", line 119, in <module>
    update_lookup('AIS', 'MMSI_lookup', 'AIS_anoniem', 'dad_vesselname', 'AIS_schip')
  File "C:\Users\jgoddijn\workspace\DataAnonDMVV\src\Main.py", line 35, in update_lookup
    c.executemany('UPDATE ? SET ?=? WHERE ?=?', lst_rev)
sqlite3.OperationalError: near "?": syntax error

I’m doing something wrong with the tuple insertion but i cannot figure what!

thanks a bunch!

  • 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-14T03:25:36+00:00Added an answer on June 14, 2026 at 3:25 am

    You cannot use SQL parameters for table or column names, only for column and result values.

    You’ll have to use conventional python string formatting to insert the name of the updated table instead.

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

Sidebar

Related Questions

i get this error when trying this: ERROR method name expected. How should i
I have a button and onclick is set to this method which should display
Hi I have this method below which should insert values into my database. However
Should I always be using this method when rendering? Does it slow down much
i don't understand this example from the doc : the timeIntervalSinceNow method should show
I have a strange problem. I have this method, which should generate a Date
[NSThread detachNewThreadSelector:@selector(colourChange) toTarget:del withObject:nil]; This should call the colourChange method in the class' delegate(del)
This should be easy but its got me stumped. I've got a button on
I've read some posts stating that using this method is not good, shouldn't be
Shouldn't I be able to call this CoffeeScript method from within an erb template?

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.