SQLite
SQLite is a lightweight, serverless database engine often used for small-scale applications and embedded systems.
Setup
GNU/Linux
To connect to the database Gretl uses the ODBC driver . The process for setting it up is described by Andrew B. Collier in an article on his blog. The article describes how to set it up on a computer running Ubuntu but it also works for other distributions.
Packages download
You need to download and install the unixODBC and SQLiteODBC packages depending on the distribution you use.
Setup files
If it is not already present you need to create an odbcinst.ini file in the /etc
folder as shown below
; /etc/odbcinst.ini file content [SQLite] Description=SQLite ODBC Driver Driver=libsqliteodbc.so Setup=libsqliteodbc.so UsageCount=1 [SQLite3] Description=SQLite3 ODBC Driver Driver=libsqlite3odbc.so Setup=libsqlite3odbc.so UsageCount=1
and an .odbc.ini
file in the home directory that specifies the name and path to the database file.
; ~/.odbc.ini file content [databaseFileName] Description = Database description Driver = SQLite3 Database = /path/to/database/file Timeout = 2000
As a final step, you need to create an environment variable that points to the .ini file.
In the example, a global environment variable is created by adding a line to the /etc/environment
file.
# # Content of /etc/environment # ODBCSYSINI=/etc
Connecting via Gretl
Once everything is set up to create a connection via Gretl and be able to retrieve data, simply use the open
command with the --odbc
flag specifying the database name given in the .odbc.ini
file.
open dsn=databaseFileName --odbc
At this point you can use the open
and data
commands as specified in the command reference.