Anderson Laverde
Anderson Laverde

Reputation: 395

How to connect to SQLite database with Node-Js?

I'm trying to connect to SQLite database with Node-Js, I can connect but with the database locally using the code below

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

I want to know if there is any way to connect to a database host in other server, not in my local project. Thanks.

Upvotes: 0

Views: 1496

Answers (1)

vicky
vicky

Reputation: 415

const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
  host: 'localhost',
  dialect: 'mysql'|'sqlite'|'postgres'|'mssql',
  operatorsAliases: false,

  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  },

  // SQLite only
  storage: 'path/to/database.sqlite'
});
use sequelize orm....

Upvotes: 1

Related Questions