How can I import a SQLite db3 file

Sorry for this question, but I never worked with SQLite, and I went through the SQLite site, downloaded the "Precompiled Binaries For Windows" files that tried to make them suitable for my purpose, but I could not, I saw with working tutorials with bases data tables.

My tasks are to get data from SQLite and put it in magento mysql DB. So, for this, I have a SQLite DB dump file as a .db3 file, a txt file with a db dump file size (20110125_SIZE).

So how can I import it into SQLite. Please, if any of you worked with SQLite3, help me understand the .db3 file and how I can see the records from them.

I have a sqlite3 db dump as dbname.db3,

So, I tried to link this sqllite with php. Here is my sample code I received from the forum.

    $db = openDatabase();   
    unset($db);

    function openDatabase() {
        $dbFile = realpath('dbname.db3');
        echo $dbFile . "\n";
        $needDbCreate = !file_exists($dbFile);
        $db = new SQLiteDatabase($dbFile) or die((file_exists($dbFile)) ? "Unable to open" : "Unable to create");
        if($needDbCreate) {

        }
        return $db;
    } 

.

: "SQLiteException" 'SQLiteDatabase:: _ construct() [sqlitedatabase.-- construct]: " C:\wamp\www\SQLITE\index.php: 23 Stack : # 0 C:\WAMP\WWW\SQLITE\index.php(23): SQLiteDatabase β†’ _ ( 'C:\WAMP\WWW\SQL...') 1 C:\wamp\www\SQLITE\index.php(15): openDatabase() # 2 {main} C:\wamp\www\SQLITE\index.php 23

sqldump PDO, .

try {       
        $dbh = new PDO("sqlite:C:\wamp\www\SQLITE\dbname.db3");
        echo 'Db Connected <br/>';

    }
    catch(PDOException $e)
    {
        echo $e->getMessage();
    }

, , , , .

, . ti php.

, .

+3
2

, SQLite, sqlite3. , , () .

sqlite3 ./database.file

, SQL , .help .dump.

, , , , .

: ( ), , .db3 SQLite3, . . , .

cat yourdump.sql|sqlite3 ./realdb.db3
+3
call three times 
$rr=exec("sqlite3 database.db \".separator '|'\" ");
$rr=exec("sqlite3 database.db \".import myfile.txt tablename\" ");
$rr= exec ("sqlite3 database.db \"pragma encoding = 'utf-8'\" ");

or 
single line 
$rr=exec("sqlite3 database.db \".separator '|'\" && sqlite3 database.db \"pragma encoding = 'utf-8'\"   && sqlite3 database.db \".import myfile.txt tablename\" ");
0

Source: https://habr.com/ru/post/1795906/


All Articles