Working With Dates In Access Using Pyodbc Giving "too Few Parameters" Error
I am using Python with a pyodbc import. I am using Microsoft Office 2013 64bit. I am attempting to query an accdb database to select distinct dates within a range and assign them t
Solution 1:
To
- save yourself the hassle of finding the applicable date delimiter, and
- promote good coding practice
you should simply use a parameterized query like this:
db = pyodbc.connect(connStr)
crsr = db.cursor()
sql = """
SELECT DISTINCT Date_ FROM Closing_prices WHERE Date_ >= ? AND Date_ < ?
"""
params = (datetime.date(2011, 8, 10), datetime.date(2014, 4, 30))
crsr.execute(sql, params)
Post a Comment for "Working With Dates In Access Using Pyodbc Giving "too Few Parameters" Error"