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, realiable 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




Test Php

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

  • 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

LEARN MORE  How To Count Words In A Sentence In Python?

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 can run our code like below

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)