Migrating SQLite for PHP 5.2 to PHP 5.4 on Ubuntu

Written by Ben Wendt

PHP 5.4 discontinued support for SQLite 2 databases. Updating an old legacy PHP application with a SQLite database to a new server is not very difficult.

To start off, you will need the SQLite binaries so that you can convert the database between versions:

sudo apt-get install sqlite sqlite3

Now that you have the binaries installed, you can convert your version 2 SQLite database to version 3:

sqlite version2.db .dump | sqlite3 version3.db

Now you will need to update your PHP script with the following translations

Old command
New command
sqlite_exec($handle, $query)
sqlite_query($handle, $query)
$handle = sqlite_open($file)
$handle = new SQLite3($file)