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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:28:02+00:00 2026-06-15T21:28:02+00:00

I try to execute this sqlite3 query in Python. I reduced the code to

  • 0

I try to execute this sqlite3 query in Python. I reduced the code to the minimum, sqlite.connect, etc works.

column = 'Pron_1_Pers_Sg'
goal = 'gender' 
constrain = 'Mann'


with con:
    cur = con.cursor()

    cur.execute("SELECT ? FROM Data where ?=?", (column, goal, constrain))
    con.commit()

    rows = cur.fetchall()

    for element in rows:
        values.append(element)

This returns an empty list.
If I hardcode the strings, it works and returns values.

  • 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-15T21:28:03+00:00Added an answer on June 15, 2026 at 9:28 pm

    Parameter markers can be used only for expressions, i.e., values.
    You cannot use them for identifiers like table and column names.

    Use this:

    cur.execute("SELECT "+column+" FROM Data where "+goal+"=?", (constrain,))
    

    or this:

    cur.execute("SELECT %s FROM Data where %s=?" % (column, goal), (constrain,))
    

    (And don’t commit before you have actually finished accessing the data.)

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

Sidebar

Related Questions

When I try to execute this statement in Oracle SQL Developer 2.1 a dialog
Okay, I'm getting this error when I try to execute this procedure. The thing
This is what I try to execute: CREATE TABLE order ( o_id INTEGER not
When I try to execute my code, I'm getting an error dialog: 'Show Disassembly'
I get the following error when I try and execute the code down below.
I'm try to insert values into my sqlite table using a python script. It
I have this line that works OK: c.execute('select cleanseq from cleanseqs WHERE newID=%s'%name) But
this is somewhat related to my earlier query.. Reading A Big File With Python
I am writing a small python script like this: #!/usr/bin/env python from sqlite3 import
I'm using eric4 (qtdesigner, pyqt, python, etc) with sqlite and I keep getting error

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.