Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php sqlite command line access

Is there anyway to access sqlite packaged with PHP via command line?

like image 696
dave Avatar asked Jul 20 '11 21:07

dave


People also ask

How do I access SQLite from command line?

Start the sqlite3 program by typing "sqlite3" at the command prompt, optionally followed by the name of the file that holds the SQLite database (or ZIP archive). If the named file does not exist, a new database file with the given name will be created automatically.


1 Answers

From the command-line, without using the php executable to execute a PHP script, you won't use the SQLite extension that's bundled with PHP.


But SQLite databases created from PHP are just standard SQLite databases (which are stored in a file), so they can be opened and manipulated with any existing SQLite client.


For example, from my Linux shell, I can use :

$ sqlite3 -header -column /home/squale/.../db/krypton-lite-scores.db
SQLite version 3.7.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from highscores;
id          name        score       latitude    longitude   timestamp 
----------  ----------  ----------  ----------  ----------  ----------
1           Squale      20          45.7686     4.8128      1310533429
2           Squale      63          45.7682     4.8131      1310579495
3           Squale      42          45.7686     4.8127      1310586793
sqlite> 

And this allows me to work with that SQLite database -- which is normally manipulated by some PHP scripts.

like image 173
Pascal MARTIN Avatar answered Sep 21 '22 15:09

Pascal MARTIN