5

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

1
  • Are you looking to access PHP created SQLite databases from the command line? Or are you looking to use PHP to access SQLite databases from the command line? PHP Comes with SQLite preinstalled as apart of it's PDO package. Commented Jul 21, 2011 at 21:27

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

There is no reason, that you may want to access the SQLite library packaged with PHP, because its just the libary packaged with PHP. SQLite-databases are just files, that you can access with any SQLite-tool, for example the common CLI-Tool

# e.g. 
$ sqlite3 myDatabase.sqlite

Using ubuntu (and probably any other debian-based linux) you can install it with

$ sudo apt-get install sqlite3

Comments

1

Download the file that fits your environment from SQLite Download Page. They are simple command line executables. Make sure that you create the SQLite DB file with Version 3 in PHP, I believe the default is often Version 2 which you cannot download and read anymore.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.