How To Create Fast Simple Database and Table With Php and Sqlite – POFTUT

How To Create Fast Simple Database and Table With Php and Sqlite

Php is web programming language very popular among developers. Php is actually a scripting language which means there is no need to compile the code to run. So write and run is the motto of php language. Php scripts can be run on Linux systems like bash, Perl scripts too. Some administrators with development background prefers php for scripting because php offers more than bash scripting. SQlite is an other popular database which is designed for simple, reliable and fast usage. Sqlite do not need any setup and service to run. Just SQlite library and create a database file like Microsoft Access mdb and work. In this tutorial we will look how to create simple and fast php application in bash which uses sqlite database for storing data.

Install Php & Sqlite

We will install required PHP and SQlite package with the following commands.

Ubuntu, Debian, Mint

Fedora,CentOS, RedHat

Install Php & Sqlite

Install Php & Sqlite

Test Php

Php installation can be tested like below. We will run simple php code with PHP  interpreter.

Test Php

Test Php

  • We can run php as above
  • php is our Php interpreter command
  • -r  will run our code “echo ‘Hi Poftut’; ” 

Initialize Sqlite Database With Php

We will create a database file with php script. And then create a table. Our php script file name is createdb.php

Run our createdb.php script like below

If we look in the current working directory we can see that there is a file named mysqlitedb.db 

Run Application

Our application will insert specified parameter into our database. Our application code is resides in insertdata.php . We insert data into table named bar with the following script.

We can run our code like below

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)