Insert LUA variables into Sqlite3 Database

sqlite3 lua program

In this short tutorial, We will try to insert lua variables into Sqlite3 database using Lua programming language.

Installing Sqlite3 in Ubuntu server :

First of all, install the Sqlite3 in ubuntu server using the following command

Create Sqlite3 Database :

Then create one Sqlite3 database using the following command.

Now asterisk.db is created in the present folder. you can connect to that database just by typing following command.

Now you have access to the SQLITE3 CLI ( Command line interface )

Creating Tables :

Now i’m going to create one sample table. My table schema is very simple with four columns.  Here is the schema.

Inserting Values to Sqlite3 using Lua Sqlite3 module:

Here is the small program to insert the variables into Sqlite3 Database using Lua lsqlite3  module.

The line SQL will create our insert query and where MOS is variable.  we need to use lua ..  operator.

Now go ahead and run the program using the following command.

Now check the database,

You can see our MOS value is successfully inserted into the database.



Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

Leave a Reply