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

Поділитися
Вставка
  • Опубліковано 2 гру 2021
  • 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 роки тому +4

    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 роки тому +2

    Your channel is very cool!
    Please make more!
    Thanks.

  • @Sirot1d
    @Sirot1d 2 роки тому +1

    Very helpful. keep as you do.

  • @khal-elbangcola8167
    @khal-elbangcola8167 2 роки тому +1

    You are amazing Sir. Thank you

    • @coderjeet
      @coderjeet  2 роки тому

      You are welcome and happy learning!

  • @tharukerajapaksha3652
    @tharukerajapaksha3652 2 роки тому +1

    Great video sir, Thank you

  • @kevinrauer
    @kevinrauer Рік тому

    Very nice tutorial.. Really explains a lot.

  • @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 ??

  • @paulhuang2030
    @paulhuang2030 Рік тому

    Thanks so much - great video

  • @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.

  • @erdincparlak7092
    @erdincparlak7092 11 місяців тому

    Güzel bir anlatım olmuş.. Teşekkürler..

  • @tripmad
    @tripmad Рік тому

    Thanks for this video👍

  • @escanortheone668
    @escanortheone668 2 роки тому +1

    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

  • @blobropch0p
    @blobropch0p Рік тому

    Thanks man you are a life saver

  • @MagicTheKrakening
    @MagicTheKrakening 10 місяців тому

    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?

  • @dogustemizsoy9081
    @dogustemizsoy9081 2 роки тому +4

    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 роки тому +3

      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 роки тому +2

      I just put up a packaging video today.

  • @kanishkakumarasiri9257
    @kanishkakumarasiri9257 6 місяців тому

    If I add react to this, nothing will different except the api calling inside the react file isn't it ?

  • @hrutvikkhunt4043
    @hrutvikkhunt4043 Рік тому

    Can i use database located in another directory?

  • @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

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 роки тому +1

    Awesome Tutorial ++++++++++++++++++++++ Thank You.

  • @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..?

  • @MatheusSilva-qm3ph
    @MatheusSilva-qm3ph 2 роки тому +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 роки тому +1

      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.

  • @shivamkapoor1827
    @shivamkapoor1827 2 роки тому +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 роки тому +1

      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.

  • @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 Рік тому +1

      @@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.

  • @tayebsida3mer923
    @tayebsida3mer923 Рік тому

    when ever i try to install better-sqlite3-prebuilds it shows an error
    can anyone help me please 🙏

  • @Zaxior
    @Zaxior 2 роки тому +4

    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.

  • @salemouail627
    @salemouail627 2 роки тому +1

    thanks so much , can u make a video on how to build with the database

  • @galaxysoul3421
    @galaxysoul3421 23 дні тому

    why can't I use require in my js file

  • @gioproyects9507
    @gioproyects9507 2 роки тому +1

    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

  • @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?

  • @prince-vp1bu
    @prince-vp1bu Рік тому

    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 😅?

  • @saulotarsobc
    @saulotarsobc Рік тому

    Top. +1

  • @matheusasilva1170
    @matheusasilva1170 2 роки тому

    At 12:35 what command did you use? As you did?

    • @coderjeet
      @coderjeet  2 роки тому +1

      .
      ode_modules\.bin\electron-rebuild.cmd

  • @abdelouahebbenouar6157
    @abdelouahebbenouar6157 2 роки тому

    I still got the errors when you rebuild electron

  • @user-qd5zq4kt6j
    @user-qd5zq4kt6j 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.

    • @user-qd5zq4kt6j
      @user-qd5zq4kt6j 2 роки тому

      @@coderjeet after installing the electron-builder, my application does not react at all to my actions. Why?

  • @teamdailycode5594
    @teamdailycode5594 Рік тому

    how to check that insert query is successfully executed in db, any flag ? @coderJeet

    • @coderjeet
      @coderjeet  Рік тому

      Yes, when you run an insert query, you will get a non zero return value if the query is successful

  • @hrutvikkhunt4043
    @hrutvikkhunt4043 Рік тому

    module not found:error!!!

  • @adamfakrullah8265
    @adamfakrullah8265 2 роки тому

    what the difference between sqlite and sqlite3?

    • @coderjeet
      @coderjeet  2 роки тому

      Sqlite3 is the latest version of the library.

  • @hubert3728
    @hubert3728 21 день тому

    where is your repo on github? ....

  • @diyatripathi503
    @diyatripathi503 5 місяців тому

    does anybody's code work?

  • @MOGE_
    @MOGE_ Рік тому

    I faced a preload error and your solution didn't work.

  • @matheusadmin4364
    @matheusadmin4364 2 роки тому

    Please give the git hub.

    • @coderjeet
      @coderjeet  2 роки тому

      Dont have one for this.

  • @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 7 місяців тому

      @@coderjeet Hmm.. is top answer -.-

    • @Zordanus
      @Zordanus 7 місяців тому

      have you found an alternative sqlite?

  • @tamirron1301
    @tamirron1301 2 роки тому +1

    Unfortunately, I've just wasted 15 hours...

  • @dwightledet5857
    @dwightledet5857 3 місяці тому

    This is awful. It might work, but the instructions are too jumpy.