Yun, Sqlite, Php and Python
How to run Sqlite on Yun
Install sqlite3-cli - 3071201-1Create a database called test1.db
sqlite3 test1.db
The response from Yun:
SQLite version 3.7.12.1 2012-05-22 02:45:53 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>
Create a table in test1.db
sqlite>CREATE TABLE Name (a INT, b TEXT); Insert some testdata
sqlite> INSERT INTO Name ( a, b) VALUES ( 5, 'Peter');
To list the contents of the table Name
sqlite> select * from Name
To exit sqlite
.exit
How to Run Sqlite3 and PHP on Arduino Yun
install php5-mod-sqlite3 - 5.4.17-1
And ofcource the other PHP modules you need
Example php5
$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]; }
How to Run Sqlite3 and Python on Arduino Yun
Install python-sqlite3 - 2.7.3-2
And ofcource the other Python modules you need
Example python script
#!/usr/bin/python # -*- coding: utf-8 -*-
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()Useful links: Sqlite python tutorial
Sqlite manual:
http://www.sqlite.org/index.html
Autoincrement
http://www.sqlite.org/autoinc.html
Installed modules
PHP
php5 - 5.4.17-1
php5-cgi - 5.4.17-1
php5-cli - 5.4.17-1
php5-mod-sqlite3 - 5.4.17-1
Python
python - 2.7.3-2
python-json - 3_4-1
python-mini - 2.7.3-2
python-openssl - 2.7.3-2
python-sqlite - 2.3.5-1
python-sqlite3 - 2.7.3-2
Sqlite
sqlite3-cli - 3071201-1