I have a MS SQL Table as follows
Device ID Timestamp Avg_PF THDV_Sum
863071010842661 2014-01-01 22:05:57 4.0 7.0
865733020495321 2016-08-19 17:20:09 0.0 0.0
865733020495321 2016-08-19 17:20:41 0.0 0.0
865733020495321 2016-08-19 17:20:41 0.0 0.0
There are 287,533 rows comprising data for 30 devices (i.e. there are 30 unique Device ID) at 10/15 mins interval. I want to retrieve data where TimeStamp date >=2018-10-01. In SSMS (SQL server 2014 Management Tool) I am able to do this easily using the following SQL
SELECT Device ID, Timestamp, Avg_PF, THDV_Sum
FROM mytable
WHERE Timestamp >= '2018-10-01'
Now I am trying to the same on python using the following way
conn = pyodbc.connect('details of SQL server')
df_select = pd.read_sql_query(sql,conn)
Here I am using the above SQL statement as sql string. However, it is retrieving the entire data starting from timestamp = 2014-01-01.
I think I need to modify the sql string in the pd.read_sql_query.
My question is how can I add filter like stuffs in sql string which I can use in pd.read_sql_query.
sqlthat you pass to the server?