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

131
Views
How to import sqlite open to another file as a module and then exec?

I'd like to open a database (*.db) creating an other script designed for opening databases, import this file in the route script file as a module and exec.

(db/connection.js):

import sqlite3 from 'sqlite3';
import { open } from 'sqlite';

async function dataBase() {
      return open({
            filename: './db/test.db',
            driver: sqlite3.Database
            });
      };

export { dataBase };

(routes/example.js):

// database connection
import dataBase from './db/connection.js';

What am I supposed to do? If I try to do such thing like the following way, an error is being thrown:

dataBase.exec("SELECT * FROM test");
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!