Last active
April 3, 2022 05:00
-
-
Save AdmiralPotato/611f53a1ad86d921c1cbb9e59330ec59 to your computer and use it in GitHub Desktop.
Just a little sqlite in node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.idea | |
*.iml | |
.data | |
node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sqlite3 = require('@vscode/sqlite3'); | |
const sqlite = require('sqlite'); | |
sqlite.open({ | |
filename: './.data/db.sqlite', | |
driver: sqlite3.Database | |
}) | |
.then((db) => { | |
db.all('SELECT * FROM goat WHERE is_grumpy = 1') | |
.then((result) => { | |
console.log(result); | |
}) | |
.catch((error) => { | |
console.error(error); | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "play_with_sqlite", | |
"version": "1.0.0", | |
"lockfileVersion": 1, | |
"requires": true, | |
"dependencies": { | |
"@vscode/sqlite3": { | |
"version": "5.0.8", | |
"resolved": "https://registry.npmjs.org/@vscode/sqlite3/-/sqlite3-5.0.8.tgz", | |
"integrity": "sha512-6wvQdMjpi1kwYI5mfzm98siEQb2mlBKX4xdNtJFj/uNqb6wqd3JOhk+5FL7geR0hduXE5lHjv+q69jtsEtUJDA==", | |
"requires": { | |
"node-addon-api": "^4.2.0" | |
} | |
}, | |
"node-addon-api": { | |
"version": "4.3.0", | |
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", | |
"integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==" | |
}, | |
"sqlite": { | |
"version": "4.0.25", | |
"resolved": "https://registry.npmjs.org/sqlite/-/sqlite-4.0.25.tgz", | |
"integrity": "sha512-gqCEcLF8FOTeW/na3SRYWLQkw2jZXgVj1DdgRJbm0jvrhnUgBIuNDUUm649AnBNDNHhI5XskwT8dvc8vearRLQ==" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "play_with_sqlite", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@vscode/sqlite3": "^5.0.8", | |
"sqlite": "^4.0.25" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment