I am using mysql2sqlite.sh to convert MySQL dump file to SQLite using PHP. Here is my code:
exec('./mysql2sqlite.sh --databases test --host=x.com -u x -ptest | sqlite3 database.sqlite');
I dont know if it is right, but the database.sqlite output file contains the next wierd characters:
SQLite format 3^@^D^@^A^A^@@^@^@^@^A^@^@^@^G^@^@^@^@^@^@^@^@^@^@^@^E^@^@^@^D^@^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^A^@-�^B ^C�^@^F^@�^@^B^P^C�^A�^Am^A^Q^@�^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@N^F^F^W%^W^Aoindexusers_branchusers^GCREATE INDEX "users_branch" ON "users" ("branch")Z^E^F^$ "id" int(11) NOT NULL , "first_name" varchar(50) NOT NULL, "last_name" varchar(50) NOT NULL, "password" varchar(100) NOT NULL, "email" varchar(100) NOT NULL, "cel" varchar(30) NOT NULL, "level" int(11) NOT NULL, "deleted" int(1) NOT NULL, "created" date NOT NULL, "modified" timestamp NOT NULL , "company_id" int(11) NOT NULL, "branch" int(11) NOT NULL, PRIMARY KEY ("id") ))^B^F^W=^W^A^@indexsqlite_autoindex_users_1users^C^@^@^@^D
I tried to add this file to my WPF project with a sqlite database
string lines = "";
try
{
using (StreamReader sr = new StreamReader(databaseFile))
{
lines += sr.ReadToEnd();
}
}
catch (Exception)
{
}
SQLiteConnection conn = new SQLiteConnection("Data Source=test.db");
conn.Open();
var command = conn.CreateCommand();
command.CommandText = lines;
command.ExecuteNonQuery();
conn.Close();
The problem is that i am getting:
Additional information: SQL logic error or missing database
near "SQLite": syntax error
Also, if i remove the:
SQLite
Word from the file, the operation does nothing.
Why is the file not getting accepted by WPF? If i use the file on SQLiteBrowser it works perfect.
Aucun commentaire:
Enregistrer un commentaire