osc2nuke's avatar

Use sqlite command-line (ui)

Perhaps this is going to be a strange question and i prob have to do my best to correctly write it down. English is not my native and coding jargon is ... well, let's not talk about that.

Here we go: I work on a Desktop app with Laravel (10) and NativePHP.

NativePHP is pretty new and allows you to build desktop Apps ( for: Windows, Linux and Mac os) with Laravel and all its features, it is really cool, it inspired me to start programming again.

Now here's the thing. When using the DB:: query's that Laravel provide, i noticed how slow my app really was. In this case, import a CVS with 115.000+ rows +/- 28MB, what took between 10 and sometimes even 20 minutes. As the code runs on my desktop i was able to hook-on to the sqlite.exe via Laravel on my machine, where it only took 2 seconds!

Here is how i did it (tvview is the Laravel project location)

In my Controller function:

        $db = "C:/wamp64/www/tvview/database/nativephp.sqlite";//location of the database
        $sql = "C:/wamp64/www/tvview/storage/app/import.sql";//sql that wil be executed
        exec("C:/wamp64/www/tvview/database/sqlite3.exe ".$db."<".$sql);
//I Copied sqlite.exe from my C:\ and putted it in my project folder.
//call sqlite3.exe
// connect to $db:
//execute the $sql

The content inside import.sql that is going to be executed via exec():

CREATE TABLE IF NOT EXISTS "channels" ("id" varchar not null, "group_title" varchar, "tvg_name" varchar, "tvg_logo" varchar, "group_type" varchar, "url" varchar, "slug" varchar, "favorite" varchar, primary key ("id"));
.mode csv
.import C:/wamp64/www/tvview/storage/app/output.csv channels

Is there some package i could use what would make this easier, especially now that i also perform a search via DB:: , what takes ages?

Thanks in advance!

PS: I spend over a week to find out about above, wasted a lot of time with the given answer(s) HERE: Laravel and SQLite dot commands

As sqlite3 simply does not support .dot commands, only via the command-line interface

0 likes
0 replies

Please or to participate in this conversation.