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

Поделиться
HTML-код
  • Опубликовано: 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.

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

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

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

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

  • @paulhuang2030
    @paulhuang2030 Год назад

    Thanks so much - great video

  • @MagicTheKrakening
    @MagicTheKrakening 11 месяцев назад

    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?

  • @erdincparlak7092
    @erdincparlak7092 Год назад

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

  • @tripmad
    @tripmad Год назад

    Thanks for this video👍

  • @hrutvikkhunt4043
    @hrutvikkhunt4043 Год назад

    Can i use database located in another directory?

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

  • @blobropch0p
    @blobropch0p Год назад

    Thanks man you are a life saver

  • @tayebsida3mer923
    @tayebsida3mer923 2 года назад

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

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

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

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

  • @galaxysoul3421
    @galaxysoul3421 Месяц назад

    why can't I use require in my js file

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

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 года назад +1

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

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

  • @abdelouahebbenouar6157
    @abdelouahebbenouar6157 2 года назад

    I still got the errors when you rebuild electron

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

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

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

  • @matheusasilva1170
    @matheusasilva1170 2 года назад

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

    • @coderjeet
      @coderjeet  2 года назад +1

      .
      ode_modules\.bin\electron-rebuild.cmd

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

  • @salemouail627
    @salemouail627 2 года назад +1

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

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

  • @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 Месяц назад

    where is your repo on github? ....

  • @saulotarsobc
    @saulotarsobc Год назад

    Top. +1

  • @MOGE_
    @MOGE_ Год назад

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

  • @diyatripathi503
    @diyatripathi503 6 месяцев назад

    does anybody's code work?

  • @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 8 месяцев назад

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

    • @Zordanus
      @Zordanus 8 месяцев назад

      have you found an alternative sqlite?

  • @matheusadmin4364
    @matheusadmin4364 2 года назад

    Please give the git hub.

    • @coderjeet
      @coderjeet  2 года назад

      Dont have one for this.

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