G
G
GayLord632019-01-15 04:30:03
SQLite
GayLord63, 2019-01-15 04:30:03

Get information from sqlite db in node.js?

Hello. Such a problem. There is a sqlite database connected to the Node.js project, interacting with 'sqlite-sync'. And here is a table in the database that stores 1 row and 2 columns:
Id - Key
1 - 892
(example)
How to get this value "892" and put it into a variable using a query in Node.js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-01-15
@GayLord63

This is not a problem
https://www.npmjs.com/package/sqlite-sync#usage
something like this

var sqlite = require('sqlite-sync');
sqlite.connect(':memory:');
sqlite.run("CREATE TABLE TableName(Id INTEGER PRIMARY KEY, Key INTEGER NOT NULL)");
sqlite.run("INSERT INTO TableName VALUES(1, 892)");
var result = sqlite.run("SELECT Key FROM TableName WHERE Id = 1");
console.log(result[0].Key);

OUT: 892

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question