Insert LUA variables into Sqlite3 Database

Spread the love

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.

 

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer, Presently working as a Software Engineer. I love Linux and Open Source. Apart from that, I love to explore new technologies and things.

Leave a Reply