Page 1 of 1

Retrieve data from mysql table using python

Posted: Sat Jan 03, 2015 2:38 pm
by Amol Desai
Hi,
I have collected data from mysql table using python as follows,
sensor=Analog Sensor 0,Interval=60
sensor=Digital Sensor 2,Interval=120
sensor=Digital Sensor 5,Interval=0
I want to read data from sensor for particular interval. So how do I select the Interval for Analog sensor 0 by using python so that I can take reading from that sensor .
Thanks in advance

Re: Retrieve data from mysql table using python

Posted: Sat Jan 03, 2015 2:55 pm
by danjperron
It is hard to respond if we don't know the structure of your table and how you did implement the table insertion?

is it three different tables ? one for each sensor or it is on the same table with a sensor id field ?

I'm confuse about interval 0. What interval do ?

I put code on how to use mysql with a card reader maybe take a look at the python3 code

[urlhttp://www.raspberrypi.org/forums/viewtopic.ph ... 44#p647644[/url]

Daniel

Re: Retrieve data from mysql table using python

Posted: Sat Jan 03, 2015 3:25 pm
by DougieLawson
If we assume you have a timestamp column then you can use a BETWEEN predicate with a start time & end time.

Re: Retrieve data from mysql table using python

Posted: Sat Jan 03, 2015 3:30 pm
by danjperron
Are you able to extract your data using normal sql console query ?

if yes than it is exactly the same with python! use the same command in a string!

Daniel