SQLite Database Server

<< Click to Display Table of Contents >>

Navigation:  Hardware Modules > aMG EthernetINF > Webserver CGI >

SQLite Database Server

Previous pageReturn to chapter overviewNext page

Description

The interface provides access to aMG SQLite Database Server board via http GET method. Build and download model webserver_demo.mdl to target for below demo.

sqlite.cgi

Syntax: /sqlite.cgi?<arg1>=<arg1_value>&<arg2>=<arg2_value>&<arg3>=<arg3_value>&...

Argument list

Name

Value

Description

action

getinfo | query

This argument is optional, default is 'query' if not specified.

getinfo - get hardware board information (Firmware version and library version).

query - input sqlite query statement.

Usage example:

http://192.168.1.41/sqlite.cgi?action=getinfo

query

<query string>

This argument cannot be empty if argument action=query.

Usage example:

http://192.168.1.41/sqlite.cgi?action=query&query=.help

mode

csv | column | html | insert | line | list | tabs | tcl

This argument equivalent to .mode <mode> in sqlite command line.

Usage example:

http://192.168.1.41/sqlite.cgi?query=select * from sensors limit 50&mode=csv

header

on | off

This argument equivalent to .header <on|off> in sqlite command line. If this argument not specified, default is 'on'

Usage example:

http://192.168.1.41/sqlite.cgi?query=select * from sensors limit 50&mode=csv&header=on

db

<database file name>

Specify database file name. If this argument not specified, default is 'database.db'.

http://192.168.1.41/sqlite.cgi?query=.tables&db=database.db

output

<sqlite query output to file> | sqlite_query.html

This argument ask server to save output of query to file to directory 'system', and also response to web browser the same file.

Usage example:

http://192.168.1.41/sqlite.cgi?query=select * from sensors limit 50&mode=csv&header=on&output=sql.csv

Then request output file (stored in directory 'system'):

http://192.168.1.41/system/sql.csv

 

Note: sqlite_query.html is reserved for demo of query form.

SQLite query demo

1. Get aMG SQLite Dataserver board firmware and library version

Query: http://192.168.1.41/sqlite.cgi?action=getinfo

Response:

webserver_cgi_sqlite_web

2. Data query

Query: http://192.168.1.41/sqlite.cgi?query=select%20*%20from%20sensors%20limit%2010&mode=csv

Response:

webserver_cgi_sqlite_web2

SQLite Form demo

The CGI accept GET method, user may create html form for input query string.

Query:

http://192.168.1.41/sqlite.cgi?query=.version&output=sqlite_query.html&mode=csv&db=database.db

Response:

webserver_cgi_sqlite_web3

Try enter some query string and Submit:

webserver_cgi_sqlite_web4

Limitation

1. Length of sqlite is limit. Due to using GET method for sqlite.cgi, HTTP request line limit to 1023 character.

2. SQLite output size is limit to 8k bytes maximum.