Using Python 3.19.
I am reading in a lines from an ever growing log file. Values from each
line of the log file are parsed and placed into a database. Each record
has a variable of type TIMESTAMP. Multiple records have the same the
same value for time stamp.
After a line is processed, I need to check if there are multiple records
with the same time stamp and count the total number of records returned.
I'm struggling trying to create a select clause to match a variable of
type TIMESTAMP.
Example Record
(datetime.datetime(2016, 10, 13, 8, 10),
u'HS_H08_20161013_0810_B09_JP03_R20_S0101.DAT', u'Himawari8', 2016, 10,
13, 8, 10, 9, u'Japan', -1, 3, u'test')
Code snipits:
#HS_H08_20161013_0000_B01_R304_R10_S0101.DAT
imageInfo['year'] = int(filenameVals[2][0:4])
imageInfo['month'] = int(filenameVals[2][4:6])
imageInfo['day'] = int(filenameVals[2][6:8])
imageInfo['hour'] = int(filenameVals[3][0:2])
imageInfo['minute'] = int(filenameVals[3][2:4])
imageInfo['band'] = int(filenameVals[4][2:4])
string_date = (str(imageInfo['year']) + '-' +
str(imageInfo['month']) + '-' +
str(imageInfo['day']) + ' ' +
str(imageInfo['hour']) + ':' +
str(imageInfo['minute']) + ':00.0')
imageInfo['dateTime'] = datetime.datetime.strptime(string_date,
"%Y-%m-%d %H:%M:%S.%f")
.......
sqlCommand = """
CREATE TABLE himawari_db (
date_time TIMESTAMP,
........
checkTime = imageInfo['dateTime']
print(checkTime)
try:
satDB.execute("SELECT * FROM himawari_db WHERE date_time=?
",(checkTime,))
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users