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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:39:49+00:00 2026-06-12T01:39:49+00:00

I kept having sql syntax error.. what am I missing in here in order

  • 0

I kept having sql syntax error.. what am I missing in here in order to pull data by day.

Here’s my python error :

pyodbc.ProgrammingError: ('42000', "[42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.63rel13.4-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s and date_created < %s ,(start, next)' at line 11 (1064) (SQLExecDirectW)")
File "d:\sasdev\datax\program\py\global.py", line 33, in <module>
  """)

Here’s the code :

start = datetime.date(2012,01,01)
next = start + datetime.date.resolution

while next <= datetime.date.today():
     print start, next 

     cur_ca.execute("""
             select id,
         date_created,
         data
         from bureau_inquiry where date_created >= %s and date_created < %s %(start, next)
         """)
     start = next
     next = start + datetime.date.resolution  
  • 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-12T01:39:50+00:00Added an answer on June 12, 2026 at 1:39 am

    You execute a query with formatting parameters but never pass these in; the % (start, next) part goes outside of the SQL query:

    cur_ca.execute("""
             select id,
         date_created,
         data
         from bureau_inquiry where date_created >= %s and date_created < %s
         """ % (start, next)
       )
    

    You would be better off using SQL parameters however, so the database can prepare the query and reuse the query plan:

    cur_ca.execute("""
             select id,
         date_created,
         data
         from bureau_inquiry where date_created >= ? and date_created < ?
         """, (start, next)
       )
    

    PyODBC uses ? for SQL parameters.

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

Sidebar

Related Questions

I kept on receiving this error Deprecated: Assigning the return value of new by
I see that tax information is kept at order level but I cannot see
I am having some weird issue here. I have a database table which has
i had kept repeater control inside Update panel. The control is having 4 columns.
I'm having difficulty using data created with canvas's todataurl() method. Currently my code sends
Kept on seeing this pattern in code, but couldn't find any reference to it
I kept 2 asp panel controls (with text boxes and buttons) in an update
Disclaimer : I kept this because some things may be useful to others, however,
I have kept hearing this statement. Switch..Case is Evil for code maintenance, but it
If HTTP persistent connection is kept alive and done on the same socket with

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.