Comments (3)
@tracker1 good question! Here is an example how to work with multiple databases:
import sqlite from 'sqlite';
import Promise from 'bluebird';
Promise.resolve()
.then(() => Promise.all([
sqlite.open('./core.sqlite', { Promise }),
sqlite.open('./data.sqlite', { Promise })
])
.then(([coreDb, dataDb]) => {
coreDb.get('SELECT * FROM Table WHERE id = ?', 123).then(row => console.log(row));
});
or, with async/await
syntax:
import sqlite from 'sqlite';
impot Promise from 'bluebird';
async function foo() {
const [coreDb, dataDb] = await Promise.all([
sqlite.open('./core.sqlite', { Promise }),
sqlite.open('./data.sqlite', { Promise })
]);
const row = await coreDb.get('SELECT * FROM Table WHERE id = ?', 123);
}
foo();
I guess it would be good to include that info into README.md
. A pull request is more than welcome!
from node-sqlite.
How to run two different migrations against different tables open?
from node-sqlite.
I've documented this in the v4 beta readme, thanks all
from node-sqlite.
Related Issues (20)
- json1 extension HOT 1
- Best way to batch create/insert or update? (How to properly use driver.serialize?) HOT 1
- Unable to open DB read only HOT 9
- Can't execute transaction HOT 3
- placeholders don't work with pragma HOT 2
- SQLCipher support HOT 2
- Problem with nullable fields in knex HOT 1
- Placeholders don't work with exec
- Exceptions don't always contain stack traces HOT 3
- The callback error does not work and an exception error is generated! HOT 4
- electron-forge make error HOT 1
- Access sqlite database which has password HOT 1
- migration logic HOT 2
- impossible to change migration configuration HOT 2
- sqlite api to create a db HOT 4
- Date and time in db.run HOT 3
- Getting multiple errors in React TypeScript HOT 1
- bun.sh driver? HOT 2
- Why are sqlite3 typings included here when sqlite3 has its own typings? HOT 9
- Unable to install Sqlite HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sqlite.