Php sqlite command line access
Is there anyway to access sqlite packaged with PHP via 开发者_运维技巧command line?
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.
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
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.
精彩评论