vendredi 3 juillet 2015

file is encrypted or is not a database - sqlite

I have some trouble to open a sqlite file

In the command line I get this:

#sqlite3 sms.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from message;
Error: file is encrypted or is not a database

The error is not when I connect, it's when I run a query

Checking the file gets me this

# file sms.db
sms.db: SQLite 3.x database

So it should not be a version problem - like opening a sqlite2 file with sqlite3

In php I have this:

try 
{
    /*** connect to SQLite database ***/

    $db = new PDO("sqlite:path/sms.db");
    echo "Handle has been created ...... <br><br>";

}
catch(PDOException $e)
{
    echo $e->getMessage();
    echo "<br><br>Database -- NOT -- loaded successfully .. ";
    die( "<br><br>Query Closed !!! $error");
}

$result = $db->query('SELECT * from message') or var_dump($db->errorInfo());

Gets me this (not at connect but when the query is executed)

array(3) { [0]=> string(5) "HY000" [1]=> int(26) [2]=> string(38) "file is encrypted or is not a database" } 

I use a Sql manager extension for firefox and there I can open the file without any problems(and run any query). This is really strange for me. I have searched about this for the last hours but I didn't find any solution. Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire