Therefore, it took me some time to figure out how to access a sqlite database from php and python.
It turned out to be quite easy, so if there are others who are in the same situation, here's what I did:
PHP:
install install php5-mod-sqlite3
example php script to conect to sqlite database ec.db on the SD card
db=new SQLite3("/mnt/sda1/arduino/www/test/ec.db");
$results = $db->query('SELECT * FROM Navn');
while ($row = $results->fetchArray()) {
var_dump($row);
print $row[1];
}
Python:
Install python-sqlite3
Example python script
#!/usr/bin/python
import sqlite3 as lite
import sys
con = None
try:
con = lite.connect('test1.db')
cur = con.cursor()
cur.execute('SELECT * from test1')
data = cur.fetchone()
print data
except lite.Error, e:
print "Error %s:" % e.args[0]
sys.exit(1)
finally:
if con:
con.close()
On Yun, you 'd have to run opkg update first before opkg install. I think this might be because it can't save the repository list. Then run "opkg install python-sqlite3". That's all!
php5 und sql works great but i have one problem to get the time in a php script on yun side
if i call
<?php
echo Date(h,m,s);
echo "
";
?>
i get the message
Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /mnt/sda1/arduino/www/Aqarium/time.php on line 4
i checked the funktion date_default_timezone_set()
but with no result