Connecting to Sqlite Database in Electron JS - (Electron & Databases)

  Рет қаралды 45,007

coderJeet

coderJeet

Күн бұрын

Nearly every application needs a database of some sort. Sqlite is a great choice for an Electron db. It's lightweight, it's portable and can process normal SQL commands. In this video I show you how to connect and work with a Sqlite database using Electron.

Пікірлер: 88
@G5STU
@G5STU 2 жыл бұрын
I’m a 43 ur old full stack dev , need to build a Win, Mac and Linux gui app. Was planning to use c++ but have now decided to use electron for speed of development , keep the vids coming my friend :)
@coderjeet
@coderjeet 2 жыл бұрын
Electron is a pretty good choice for rapid development. I've commercially released one app so far in it, and my second one is nearly ready to hit production.
@MatheusSilva-qm3ph
@MatheusSilva-qm3ph 2 жыл бұрын
Your channel is very cool! Please make more! Thanks.
@coderjeet
@coderjeet 2 жыл бұрын
Thank you, I will
@Zaxior
@Zaxior 2 жыл бұрын
In case of 'table **** not found' even if name has match, try this: const sqlite = require('better-sqlite3-with-prebuilds'); const path = require('path'); const db = sqlite(path.resolve(__dirname, '../local.db'), {fileMustExist: true}); exports.db = db;
@coderjeet
@coderjeet 2 жыл бұрын
Thank you for the tip!
@Zaxior
@Zaxior 2 жыл бұрын
@@coderjeet btw, is there any chace to not refresh app after one of the methods to store/get data in sql is called?
@coderjeet
@coderjeet 2 жыл бұрын
@@Zaxior Don't understand your question
@Zaxior
@Zaxior 2 жыл бұрын
@@coderjeet Basically as long as I don't use: db.exec(); all works fine, but as soon I call it, it refresh my whole app. I'm using react redux where I can keep my temp data in state, after app refresh it gone.
@Sirot1d
@Sirot1d 2 жыл бұрын
Very helpful. keep as you do.
@coderjeet
@coderjeet 2 жыл бұрын
Thanks
@vishnukathika2546
@vishnukathika2546 2 жыл бұрын
For Connecting to Databases like Ibm db2 and mysql what package should be installed.For me when i tried to run the application then in the console i am getting an error Unreferenced error for the var=require('mysql') in my javascript file.So my doubt render process does not have node apis ??
@khal-elbangcola8167
@khal-elbangcola8167 2 жыл бұрын
You are amazing Sir. Thank you
@coderjeet
@coderjeet 2 жыл бұрын
You are welcome and happy learning!
@tharukerajapaksha3652
@tharukerajapaksha3652 2 жыл бұрын
Great video sir, Thank you
@coderjeet
@coderjeet 2 жыл бұрын
Glad you liked it
@galaxysoul3421
@galaxysoul3421 3 ай бұрын
why can't I use require in my js file
@MatheusSilva-qm3ph
@MatheusSilva-qm3ph 2 жыл бұрын
I'm starting to study now, and I don't know much about databases, but what I understand is that when I compile my program and pass it on to someone else, the database will be created if it doesn't exist, am I right? Thank you
@coderjeet
@coderjeet 2 жыл бұрын
You can ship the basic (empty) db file alongside your setup. If you want the db to be created, you'll need to write a function that'll create the db on first run.
@erdincparlak7092
@erdincparlak7092 Жыл бұрын
Güzel bir anlatım olmuş.. Teşekkürler..
@s1mple511
@s1mple511 Жыл бұрын
Hey it's already 3 days without sleeping and i cant figure out npm better-sqlite3-with-prebuilds and i receive error ERR! gyp ERR! can you help me..?
@shivamkapoor1827
@shivamkapoor1827 2 жыл бұрын
I am trying to make offline desktop app so plz tell me Is ipc needed to make crud application in electron or i have to use express in electron? But if i use express in electron it will work as online desktop aap in production.I dont find solution any where, if you can reply in this reguard.
@coderjeet
@coderjeet 2 жыл бұрын
You can use Express if you want to. It can be used in both online and offline apps. IPC is available to an express app too. However, I recommend KOA instead of Express if you start out now.
@kevinrauer
@kevinrauer Жыл бұрын
Very nice tutorial.. Really explains a lot.
@coderjeet
@coderjeet Жыл бұрын
Thanks mate
@paulhuang2030
@paulhuang2030 Жыл бұрын
Thanks so much - great video
@kanishkakumarasiri9257
@kanishkakumarasiri9257 9 ай бұрын
If I add react to this, nothing will different except the api calling inside the react file isn't it ?
@gioproyects9507
@gioproyects9507 2 жыл бұрын
how i run the ./node_modules/.bin/electron-rebuild ?
@geniusidea6026
@geniusidea6026 2 жыл бұрын
You can use git bash (windows) or . ode_modules\.bin\electron-rebuild.cmd
@escanortheone668
@escanortheone668 2 жыл бұрын
hey i am using electron forge with react, sqlite3 and typeorm when i am trying making the package , the sqlite3 file is not exporting with bundle is there any solution and not even creating ? and thanks a lots for amazing tutorial
@dogustemizsoy9081
@dogustemizsoy9081 2 жыл бұрын
Such a good video , i would love to see on how the packaging works for linux and others thank you !! I'm having really hard time on packaging. I can use this system with react too right?
@coderjeet
@coderjeet 2 жыл бұрын
Yes, you can use node.js with react, there is a separate setup for it though and you can find videos online on that. I am making training on packaging, we'll have it up soon.
@coderjeet
@coderjeet 2 жыл бұрын
I just put up a packaging video today.
@tripmad
@tripmad Жыл бұрын
Thanks for this video👍
@blobropch0p
@blobropch0p Жыл бұрын
Thanks man you are a life saver
@coderjeet
@coderjeet Жыл бұрын
You are welcome
@hrutvikkhunt4043
@hrutvikkhunt4043 2 жыл бұрын
Can i use database located in another directory?
@MatheusSilva-qm3ph
@MatheusSilva-qm3ph 2 жыл бұрын
Very cool. But I have a problem, when I try to add an item by clicking on a button it returns " Fatal error: throw as JavaScript exception napi_throw". Do you have any idea how to help me? It's a CRUD.
@tayebsida3mer923
@tayebsida3mer923 2 жыл бұрын
when ever i try to install better-sqlite3-prebuilds it shows an error can anyone help me please 🙏
@mohamedyoussef8835
@mohamedyoussef8835 2 жыл бұрын
Awesome Tutorial ++++++++++++++++++++++ Thank You.
@coderjeet
@coderjeet 2 жыл бұрын
Thank you ! :)
@diyatripathi503
@diyatripathi503 8 ай бұрын
does ur code works?
@MagicTheKrakening
@MagicTheKrakening Жыл бұрын
Took a few years off from dev work. Come from front end design world and doing my first personal project that will push me into the backend dev world. Any tips on how to properly build a database for a beginner?
@hubert3728
@hubert3728 3 ай бұрын
where is your repo on github? ....
@abdelouahebbenouar6157
@abdelouahebbenouar6157 2 жыл бұрын
I still got the errors when you rebuild electron
@prince-vp1bu
@prince-vp1bu 2 жыл бұрын
Hi, I'm having an error in . ode_modules\.bin\electron-rebuild.cmd it keeps giving me an error which is : An unhandled error occurred inside electron-rebuild node-gyp failed to rebuild 'C:\Users\Admin\Desktop\Test ode_modules\better-sqlite3-with-prebuilds'. For more information, rerun with the DEBUG environment variable set to "electron-rebuild". Error: Could not find any Python installation to use why i'm having an error like this? can you suggest some solution for this 😅?
@anikokey7716
@anikokey7716 2 жыл бұрын
same any fixed for this?
@anserwaseem3362
@anserwaseem3362 Жыл бұрын
@@anikokey7716 did you find any solution?
@ДмитрийБелкин-и8ю
@ДмитрийБелкин-и8ю 2 жыл бұрын
you wrapped js in Electron, but I want to wrapper React.js in Electron and connect to sqlite. Is it really?
@coderjeet
@coderjeet 2 жыл бұрын
Yep, you can absolutely do that.
@ДмитрийБелкин-и8ю
@ДмитрийБелкин-и8ю 2 жыл бұрын
@@coderjeet after installing the electron-builder, my application does not react at all to my actions. Why?
@matheusasilva1170
@matheusasilva1170 2 жыл бұрын
At 12:35 what command did you use? As you did?
@coderjeet
@coderjeet 2 жыл бұрын
. ode_modules\.bin\electron-rebuild.cmd
@teamdailycode5594
@teamdailycode5594 2 жыл бұрын
how to check that insert query is successfully executed in db, any flag ? @coderJeet
@coderjeet
@coderjeet 2 жыл бұрын
Yes, when you run an insert query, you will get a non zero return value if the query is successful
@adamfakrullah8265
@adamfakrullah8265 2 жыл бұрын
what the difference between sqlite and sqlite3?
@coderjeet
@coderjeet 2 жыл бұрын
Sqlite3 is the latest version of the library.
@salemouail627
@salemouail627 2 жыл бұрын
thanks so much , can u make a video on how to build with the database
@coderjeet
@coderjeet 2 жыл бұрын
Thanks for the suggestion
@salemouail627
@salemouail627 2 жыл бұрын
i mean packaging ^^ thNkss
@hrutvikkhunt4043
@hrutvikkhunt4043 2 жыл бұрын
module not found:error!!!
@RSurya99
@RSurya99 2 жыл бұрын
Can i get the source code of this project? I have try following your video but still got an error like this when I try to do electron-rebuild : "Error: Could not find any Visual Studio installation to use"
@coderjeet
@coderjeet 2 жыл бұрын
Sorry, I didn't put this one in a repo.
@JuanCarlos611
@JuanCarlos611 2 жыл бұрын
To fix that error you need to install Visual C++ Build Environment from here: visualstudio.microsoft.com/es/thank-you-downloading-visual-studio/?sku=BuildTools
@anserwaseem3362
@anserwaseem3362 Жыл бұрын
@@JuanCarlos611 and then do what?
@MOGE_
@MOGE_ Жыл бұрын
I faced a preload error and your solution didn't work.
@coderjeet
@coderjeet Жыл бұрын
So sad to know
@ShawneeConsulting
@ShawneeConsulting Жыл бұрын
Thanks @coderJeet! Great vids. Having an issue with preload.js in your examples in this vid. If preload.js file is empty no error, but when I add code as in the vid I get error unable to load preload script and gives the the correct path. Any suggestions?
@ShawneeConsulting
@ShawneeConsulting Жыл бұрын
seems to use contextbrige, you also have to have contextIsolation: true in webPreferences... and double check your paths :)
@coderjeet
@coderjeet Жыл бұрын
Thanks for pointing out
@MrFenoma
@MrFenoma 2 жыл бұрын
Hi first congratulate you for the video. I wanna ask you something. I didn't understand what you did with electron-rebuild, when you mention you had to set the whole path. I followed "npm i -D electron-rebuild" and then "npm i" but still receiving the same error. what Am I missing? Thanks!
@shanjainavithar1169
@shanjainavithar1169 2 жыл бұрын
same issue have you got the solution?
@anserwaseem3362
@anserwaseem3362 Жыл бұрын
@@shanjainavithar1169 did anyone got the solution?
@ShawneeConsulting
@ShawneeConsulting Жыл бұрын
@@anserwaseem3362 I used ./node_modules/.bin/electron-rebuild in the terminal (can't see the underscore very well in the vid) and it fixed the issue. It's using the full relative path to call electron-rebuild.
@diyatripathi503
@diyatripathi503 8 ай бұрын
does anybody's code work?
@godfreychiumia3925
@godfreychiumia3925 8 ай бұрын
Mine is not working.....
@saulotarsobc
@saulotarsobc Жыл бұрын
Top. +1
@coderjeet
@coderjeet Жыл бұрын
Appreciate it!
@tamirron1301
@tamirron1301 2 жыл бұрын
Unfortunately, I've just wasted 15 hours...
@coderjeet
@coderjeet 2 жыл бұрын
??
@zeljkobanovic4398
@zeljkobanovic4398 Жыл бұрын
As usual... When working with namespaces (the most idiotic way of importing) I got stuck with scope for more than an hour and at the end it just cracked ... Unable to rebuild it on windows 10
@coderjeet
@coderjeet Жыл бұрын
Hmm..
@Zordanus
@Zordanus 10 ай бұрын
@@coderjeet Hmm.. is top answer -.-
@Zordanus
@Zordanus 10 ай бұрын
have you found an alternative sqlite?
@matheusadmin4364
@matheusadmin4364 2 жыл бұрын
Please give the git hub.
@coderjeet
@coderjeet 2 жыл бұрын
Dont have one for this.
@dwightledet5857
@dwightledet5857 5 ай бұрын
This is awful. It might work, but the instructions are too jumpy.
ELECTRON: why people HATE it, why devs USE it
17:19
The Linux Experiment
Рет қаралды 190 М.
Running With Bigger And Bigger Lunchlys
00:18
MrBeast
Рет қаралды 95 МЛН
Encrypt SQLite Databases with SQLCipher
14:58
NeuralNine
Рет қаралды 13 М.
Storing Data in Electron JS Applications  - 4 Methods
20:57
coderJeet
Рет қаралды 27 М.
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 48 М.
SQLite3 in Node with better-sqlite3
12:08
Caleb Curry
Рет қаралды 7 М.
Electron with React JS under 40 min!
36:36
Eincode
Рет қаралды 87 М.
What’s Up with Laravel? It’s Everywhere, and Here’s Why!
6:22
LINQ's INSANE Improvements in .NET 9
11:26
Nick Chapsas
Рет қаралды 45 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 412 М.
Up and Running with SQLite3 in a NodeJS API
47:16
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 2,6 М.