Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
how to call sql queries from js files in index.html

I managed to install sqlite in electron but now i have the problem of how to call sql queries in my html file. I tried using the following code in index.html

<script type='text/javascript' src='query_table.js'></script>

in query_table.js:

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('db.sqlite');

function hello() {
 
    console.log("sssssssssssssssssssssssssssssssssssssssssssss");
    db.serialize(() => {
 

        db.each("SELECT *  FROM events", (err, row) => {
            console.log(row.id + ": " + row.data);
        });
       });
       
       db.close();
}

but I get this error when I launch my app:

Uncaught ReferenceError: require is not defined

what is the right way to call functions using the db? i would like to create several js files based on the various models i have (tables in my db). I would like to import a model to run sql queries based on where I am within my app. How should this be done? What is the best practice?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!