I use pypyodbc to select data from an access database. I am using the following query with the three parameters that were specified.
I tried several varieties, but to no avail. I do not see anything wrong with my syntax.
SELECT [Date], [Time], [uSec], [threeR], [twoCV]
FROM [table_a]
WHERE (Date = ? AND Time > ?)
OR (Date > ?)
Parameters have the following types:
[datetime.date, datetime.time, datetime. date]
Which when printing:
1900-09-16 , 00:00:00, 1900-09-16
pypyodbc.DatabaseError: ('07002', '[07002] [Microsoft] [ODBC Microsoft Access Driver] Too few parameters. Expected 4.')
def pullData(self):
con = pypyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};DBQ=F:/database.mdb')
cur = con.cursor()
columnListODBC = '[thisDate], [thisTime]'
for y in myTable.getColumns():
columnListODBC = columnListODBC + ', [' + y + "]"
print(columnListODBC)
for row in curSQL.execute('SELECT MAX(Datetime) FROM [' + _.getName() + ']'):
xDateTime = datetime.datetime.strptime(row[0], "%Y-%d-%m %H:%M:%S")
day = xDateTime.date()
time = xDateTime.time()
queryString = 'SELECT ' + columnListODBC + ' FROM [' + _.getName() + '] WHERE (thisDate = ? AND thisTime > ?) OR (thisDate > ?)'
print(queryString, ", ", day, ", ", time)
cur.execute(queryString, [day,time,day])
Print 1 : [thisDate], [thisTime], [uSec], [threeR], [twoCV]
Print 2 : SELECT [thisDate], [thisTime], [uSec], [threeR], [twoCV] FROM [table_a] WHERE (thisDate =? AND thisTime>?) OR (thisDate>?), 1900-09-16, 00:00:00
: , , , . . , .
SELECT [Date], [Time], [uSec], [twoCV]
FROM [table_a]
WHERE (Date = ? AND Time > ?)
OR (Date > ?)
2. . :
SELECT [thisDate], [thisTime], [uSec], [threeR], [twoCV]
FROM [table_a]
WHERE ([thisDate] = ? AND [thisTime] > ?)
OR ([thisDate] > ?)
[Microsoft] [ODBC Microsoft Access Driver] . 5.
3. , .
