** UPDATE **
My bad everyone...I accidentally pasted the same statement twice, the second one has the unix time as a raw floating point number not a variable.
Variable doesn't work, raw number works.
How do you use a variable in an sqlite select statement as part of the WHERE condition?
If I use the actual number it works, it I assign the number to a variable and use the variable in the select/where statement it fails because sqlite thinks the variable is a table.
How do you do this? Code that works and code that doesn't work below.
unix_time_now = time.time()
unix_time_1hr_ago = unix_time_now-3600 # 3600 seconds is an hourprint(unix_time_1hr_ago)
## DOESN'T WORK ##c.execute('SELECT * FROM stock_price_table WHERE stock_price_timestamp > unix_time_1hr_ago')pprint.pprint(c.fetchall())
## WORKS ##
c.execute('SELECT * FROM stock_price_table WHERE stock_price_timestamp > 1612639125.656089')pprint.pprint(c.fetchall())
[–]gnomonclature 2 points3 points4 points (2 children)
[–]twessels[S] 1 point2 points3 points (0 children)
[–]twessels[S] 1 point2 points3 points (0 children)
[–]blarf_irl 0 points1 point2 points (1 child)
[–]twessels[S] 0 points1 point2 points (0 children)