Skip to content

Instantly share code, notes, and snippets.

@loic-moriame
Created July 24, 2015 09:23
Show Gist options
  • Save loic-moriame/b321dcc38dba8a40a1f7 to your computer and use it in GitHub Desktop.
Save loic-moriame/b321dcc38dba8a40a1f7 to your computer and use it in GitHub Desktop.
node.js + sequelize + sqlite
'use strict';
var Sequelize = require('sequelize');
var sequelize = new Sequelize('mainDB', null, null, {
dialect: "sqlite",
storage: './test.sqlite',
});
sequelize
.authenticate()
.then(function(err) {
console.log('Connection has been established successfully.');
}, function (err) {
console.log('Unable to connect to the database:', err);
});
// MODELS
var User = sequelize.define('User', {
username: Sequelize.STRING,
password: Sequelize.STRING
});
// SYNC SCHEMA
sequelize
.sync({ force: true })
.then(function(err) {
console.log('It worked!');
}, function (err) {
console.log('An error occurred while creating the table:', err);
});
{
"main": "index.js",
"dependencies": {
"sequelize": "^3.4.1",
"sqlite3": "^3.0.9"
}
}
@akvsh-r
Copy link

akvsh-r commented Apr 11, 2018

@Moriame 3 years still useful. I would love to know the journey after this...

@delino12
Copy link

Honestly i can't believe am already falling in love with sequelize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment