Giter Club home page Giter Club logo

better-sqlite3's People

Contributors

bengotow avatar cclauss avatar ceymard avatar chicken avatar danielbarela avatar dependabot[bot] avatar destyk avatar jochenschmich-aeberle avatar joshuawise avatar kdabir avatar m4heshd avatar mandel59 avatar mceachen avatar mrawdon avatar neoxpert avatar paulfitz avatar pdehaan avatar pelotom avatar prinzhorn avatar qwerty541 avatar shatgupt avatar sirwaddles avatar stonecypher avatar tessro avatar thonkinator avatar threema-danilo avatar tniessen avatar tobbez avatar vazra avatar vicb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

better-sqlite3's Issues

Electron + better-sqlite3 getting error "A dynamic link library (DLL) initialization routine failed. "

Hello,

I'm using 1.4.0 of better-sqlite3, with Electron 1.4.15 and node 6.5.0, on Windows 64bit. I've installed it using npm install --save better-sqlite3. When this line executes: var Database = require('better-sqlite3'); I get an exception that dll init failed, see below for stack trace. The better_sqlite3.node is in the location that require.resolve is looking for it.

Is there anything else I need to do to make this work? node-gyp rebuild specifying --arch=x64 --target_platform=win32 ?
Thanks
Greg.

D:\devtools\js\tutorials\electrontest>npm install --save better-sqlite3

> [email protected] install D:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3
> node install


D:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "C:\Program Files\nodej
s\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  unpack_sqlite_dep
  sqlite3.c
  win_delay_load_hook.cc
  sqlite3.vcxproj -> D:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\build\Release\\sqlite3.lib
  int64.cc
  data.cc
  database.cc
  statement.cc
  transaction.cc
  open.cc
  close.cc
  binder.cc
d:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\src\binder\get-error.cc(9): warning C4267: 'initializing': conv
ersion from 'size_t' to 'int', possible loss of data (compiling source file ..\src\binder\binder.cc) [D:\devtools\js\tutorials\el
ectrontest\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
d:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\src\binder\bind-buffer.cc(8): warning C4267: 'argument': conver
sion from 'size_t' to 'int', possible loss of data (compiling source file ..\src\binder\binder.cc) [D:\devtools\js\tutorials\elec
trontest\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
  multi-binder.cc
  better_sqlite3.cc
  win_delay_load_hook.cc
     Creating library D:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\build\Release\better_sqlite3.lib and obje
  ct D:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\build\Release\better_sqlite3.exp
  Generating code
  Finished generating code
  better_sqlite3.vcxproj -> D:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\build\Release\\better_sqlite3.node
[email protected] D:\devtools\js\tutorials\electrontest
`-- [email protected]

Exception:

"Error: A dynamic link library (DLL) initialization routine failed.
\\?\d:\devtools\js\tutorials\electrontest\node_modules\better-sqlite3\build\Release\better_sqlite3.node
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:583:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at bindings (d:\devtools\js\tutorials\electrontest\node_modules\bindings\bindings.js:76:44)"

32-bit build succeeds, throws exceptions at runtime about integer length

Hey! I know these issues are bordering on the obscure, but I'm still fighting with the Windows builds of N1. We target ia32 instead of x64 on Windows because it's more widely supported, and it looks like there are some casting warnings at compile time that result in the module not working when the app runs. I believe this issue is only reproducible if you're targeting a 32-bit architecture.

Here are a few of the warnings:

c:\users\ieuser\documents\n1\node_modules\bettersqlite3\src\objects\int64\../../util/macros.h(33): warning C4146: unary minus operator applied to unsigned type, result still unsigned (..\src\objects\int64\int64.cc) [C:\Users\IEUser\Documents\N1\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
c:\users\ieuser\documents\n1\node_modules\bettersqlite3\src\objects\int64\../../util/macros.h(33): warning C4146: unary minus operator applied to unsigned type, result still unsigned (..\src\util\data.cc) [C:\Users\IEUser\Documents\N1\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
c:\users\ieuser\documents\n1\node_modules\better-sqlite3\src\objects\statement\../../util/macros.h(33): warning C4146: unary minus operator applied to unsigned type, result still unsigned (..\src\objects\database\database.cc) [C:\Users\IEUser\Documents\N1\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]

When you run the app, it complains about the 32-bit integers:

932:1011/192644:INFO:CONSOLE(28)] "TypeError: Expected both arguments to be 32 bit signed integers.
    at TypeError (native)
    at Object.<anonymous> (C:\Users\IEUser\Documents\N1\node_modules\better-sqlite3\index.js:8:34)

If you have a Windows machine, you can reproduce this by running this to build. I'm not 100% sure the warnings are causing the issue, but they seem like a very likely culprit. I wonder if there just need to be different types used here: https://github.com/bengotow/better-sqlite3/blame/n1-1.3.6/src/util/macros.h#L32

npm install --msvs_version=2013 --target=1.4.1 --arch=ia32 --target_platform=win32 --dist-url=https://atom.io/download/atom-shell

Compilation (installation via npm) fails on OS X El Capitan

Possibly of limited interest as this is not the latest version of OS X, and you're unlikely to have the hardware to reproduce it, but I thought I'd report it.

% node --version
v7.0.0

% npm --version
3.10.3

% clang --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

% npm install better-sqlite3

> [email protected] install [...]/node_modules/better-sqlite3
> node install

  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3150000/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/better_sqlite3/src/objects/int64/int64.o
  CXX(target) Release/obj.target/better_sqlite3/src/util/data.o
  CXX(target) Release/obj.target/better_sqlite3/src/objects/database/database.o
  CXX(target) Release/obj.target/better_sqlite3/src/objects/statement/statement.o
In file included from ../src/objects/statement/statement.cc:20:
../src/objects/statement/util.cc:11:48: error: no member named 'GetHiddenValue'
      in 'v8::Object'
                return v8::Local<v8::Object>::Cast(handle()->GetHiddenVa...
                                                   ~~~~~~~~  ^
../src/objects/statement/util.cc:23:13: error: no member named 'SetHiddenValue'
      in 'v8::Object'
                handle()->SetHiddenValue(Nan::EmptyString(), namedParams);
                ~~~~~~~~  ^
2 errors generated.
make: *** [Release/obj.target/better_sqlite3/src/objects/statement/statement.o] Error 1

Electron - Error: A dynamic link library (DLL) initialization routine failed.

Hi,
I installed better-sqlite3 without any issue.

But on : var Database = require('better-sqlite3') I have this error

Exception has occurred: Error
Error: A dynamic link library (DLL) initialization routine failed.
\?\d:\Users\Antoine\Documents\Visual Studio 2017\Projects\electronSqlite\node_modules\better-sqlite3\build\Release\better_sqlite3.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at bindings (d:\Users\Antoine\Documents\Visual Studio 2017\Projects\electronSqlite\node_modules\bindings\bindings.js:76:44)
at Object. (d:\Users\Antoine\Documents\Visual Studio 2017\Projects\electronSqlite\node_modules\better-sqlite3\lib\database.js:5:38)

Windows 10
Node 6.9.2
Electron 1.6.10
Npm 3.10.9
Better-sqlite3 2.3.3

I have another project with node-sqlite that works well.

Thanks.

Using sqlite3_update_hook

It would be nice to be able to subscribe to events using the sqlite3_update_hook function.

How about adding a setUpdateHook() method to the Database instance ?

I know that this function only fires for updates within the same database connection, but it would still be of use to me (probably).

Anonymous Parameters do not function properly

I am trying to utilize anonymous parameters in a prepared query, and I can not for the love of God figure out where I am going wrong. This code:

"use strict";

const Database = require('better-sqlite3');

var db;

var openConnection = function() {
	db = new Database("G:\\UserDir\\Desktop\\TestDB\\Test.db");
};

var getData = function(query, params) {
	var statement = db.prepare('SELECT * FROM ? WHERE ID = ?');
	return statement.get("Title", 1);
};

var runQuery = function(query, params) {
	return db.prepare(query).run(params);
}

module.exports = {
	open: openConnection,
	get: getData,
	run: runQuery
};

produces, at run time, this error message:

Error: Failed to construct SQL statement (near "?": syntax error).
    at Error (native)
    at Object.getData [as get] (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\lib\modules\db-holder\index.js:12:21)
    at Command.fn (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\lib\commands\test.js:21:23)
    at App.parseInput (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\node_modules\clapp\dist\App.js:399:24)
    at Client.bot.on.msg (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\lib\index.js:39:9)
    at emitOne (events.js:96:13)
    at Client.emit (events.js:188:7)
    at MessageCreateHandler.handle (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:120:65)
    at WebSocketManager.eventMessage (C:\Users\Pascal\AppData\Roaming\npm\node_modules\dbtest\node_modules\discord.js\src\client\websocket\WebSocketManager.js:273:31)

Inserting the values into the query directly works properly, and connection to the database is being successfully made. I will, however, not concatenate together queries that may or not contain potential user input, and as such would like to utilize this feature. Can someone tell me where I am going wrong, or look into fixing this if it's not on my end? Will gladly provide any additional information that may be required.

Nested transactions?

I have a piece of code like this:

}).then(function(fileList) {
    return Sync.updateSyncedPaidDataset(datasetId);
}).then(function() {
    return MediaStorage.movePicturesToAws(datasetId);
});

Where both updateSyncedPaidDataset and movePicturesToAws are enclosed in transactions (each in its own), but I need the two calls to be a single atomic operation. Nested transactions are supported in sqlite throught SAVEPOINT-RELEASE but it seems that there isn't a way to use SAVEPOINT in better-sqlite3.

Issue installing

Trying to install in windows. I am getting the following error:

d:\teste>npm install better-sqlite3

> [email protected] install d:\teste\node_modules\better-sqlite3
> node tools/install

==> cwd: d:\teste\node_modules\better-sqlite3
==> d:\teste\node_modules\lzz-gyp\lzz-compiled\windows.exe -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_
sqlite3.lzz
Error: exit code 3221225506
    at ChildProcess.<anonymous> (d:\teste\node_modules\lzz-gyp\lib\exec.js:19:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
npm WARN enoent ENOENT: no such file or directory, open 'd:\teste\package.json'
npm WARN teste No description
npm WARN teste No repository field.
npm WARN teste No README data
npm WARN teste No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node tools/install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\N\AppData\Roaming\npm-cache\_logs\2017-06-30T14_47_43_072Z-debug.log

LZZ-GYP seems to be failing to run but i cannot find a way to see the error

Cannot install locally in Win10

Hello, I'm having trouble trying to install your software in my Windows 10 machine. When I try to install it with npm I get the following output:

> [email protected] install C:\Users\caom9\Documents\pako\node_modules\better-sqlite3
> node install


C:\Users\caom9\Documents\pako\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\caom9\Documents\pako\node_modules\better-sqlite3\build\deps\action_before_build.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\caom9\Documents\pako\node_modules\better-sqlite3
gyp ERR! node -v v7.4.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the better-sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs better-sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls better-sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\caom9\Documents\pako\npm-debug.log

Before that, I was getting a different output that told me to install Python and MS Visual Studio 2005, which I did, but I still can't install your software.

I don't know if this is of any relevance but I want to use better-sqlite3 version 2.3.3 with Electron 1.6.8, which uses Node version 7.4.0 (not the latest version). This is the same Node version that I'm using to install better-sqlite3.

Anyway, I attached the corresponding log file.

npm-debug.txt

Is there a way to perform a synchronous all()?

Is it possible to wait until the query is finished? I have something like:

function query(fields, table) {
  db.on('open', () => {
    return db.prepare(`SELECT ${fields} FROM ${table}`).all()
  })
}

let rows = query('*', 'user')
console.log(rows) // is returning undefined. I need this to wait until all() is finished.

thanks!

Failed to install

$ npm install --save better-sqlite3
...
if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;
"$CI" was unexpected at this time.
....

Environment:
node: v6.4.0
npm: v3.10.6
os: Windows 10

Support Nodejs v7.0.0

npm install better-sqlite3 fails with:

In file included from ../src/objects/statement/statement.cc:20:0:
../src/objects/statement/util.cc: In member function ‘virtual v8::Local<v8::Object> Statement::GetBindMap()’:
../src/objects/statement/util.cc:11:48: error: ‘class v8::Object’ has no member named ‘GetHiddenValue’
   return v8::Local<v8::Object>::Cast(handle()->GetHiddenValue(Nan::EmptyString()));
                                                ^
../src/objects/statement/util.cc:23:13: error: ‘class v8::Object’ has no member named ‘SetHiddenValue’
   handle()->SetHiddenValue(Nan::EmptyString(), namedParams);
             ^

OS: Debian 8.6 (jessie)
node: v7.0.0
npm: 3.10.8

Parse JSON1 fields?

I wonder if it would be a good idea to convert JSON1 fields to JS values when they are read, that would avoid allocating an intermediate JS string.

Since there is no way short of reading the schema to know that a column is JSON1, this would be something passed as an option to the query…

How to use transactions

UPDATE

Transactions have been reworked in version 5.0.0, and they are now well-documented here.

ORIGINAL POST

In response to #48 (comment)

You can use db.transaction() like this:

var transaction = db.transaction([
  'INSERT INTO movies (title, rating) VALUES (@title, @rating)',
  'INSERT INTO cast_members (name, movie) VALUES (@actorName, @title)'
]);
transaction.run({ title: 'Taxi Driver', rating: 100, actorName: 'Robert De Niro' });

If you need to run javascript code in your transaction, you must manage the transaction manually. This is easier if you create a nice utility like this:

var begin = db.prepare('BEGIN');
var commit = db.prepare('COMMIT');
var rollback = db.prepare('ROLLBACK');

// Higher order function - returns a function that always runs in a transaction
function asTransaction(func) {
  return function (...args) {
    begin.run();
    try {
      func(...args);
      commit.run();
    } finally {
      if (db.inTransaction) rollback.run();
    }
  };
}

Then you can run arbitrary transactions like this:

var insertMovie = db.prepare('INSERT INTO movies (title, rating) VALUES (@title, @rating)');
var insertActor = db.prepare('INSERT INTO cast_members (name, movie) VALUES (@actorName, @title)');

var insertMovieAndActor = asTransaction(function (data) {
  insertMovie.run(data);
  // run arbitrary javascript code
  insertActor.run(data);
});

insertMovieAndActor({ title: 'Taxi Driver', rating: 100, actorName: 'Robert De Niro' });

Inserting parameter into LIKE operator in prepared statement

I can not get the prepare command to work when trying to insert a variable into the WHERE x LIKE '__' statement.

I have tried these so far:

db.prepare("select * from CARDS_VIEW where name like ? limit ?").all(name, limit)
db.prepare("select * from CARDS_VIEW where name like '?' limit ?").all(name, limit)
db.prepare("select * from CARDS_VIEW where name like ? limit ?").all('\''+name+'\'', limit)
db.prepare("select * from CARDS_VIEW where name like ? limit ?").all([name, limit])

For the first and last option, I get the error code SQLite: database schema has changed.. For the second option I get Too many parameters were provided..

For now, I've gotten around it by concatenating the name variable into the statement, but that does not sanitize the input. Is there any way I can insert a variable into the LIKE operator?

Shared Cache/Other flags

Looking through the code I learned saw that you do not allow URI names outside of internal use. I was wondering if there will be support for shared cache on a local file that is not in memory or for sqlite flags (https://www.sqlite.org/c3ref/open.html). I noticed in you use this:

status = sqlite3_open(filename, &db_handle);

to create you db. Will there be support in the future for flags by using the following to create your db?

status = sqlite3_open(filename, &db_handle, flags, zVfs);

Feedback wanted: SQLite3 Extensions

As of v3.3.0 of better-sqlite3, SQLite3 extensions are now supported.

You can load them easily with the Database#loadExtension() function. However, part of me is not satisfied.

Personally I don't use extensions, but I imagine it would be a pain in the butt to manually recompile all of your extensions every time better-sqlite3 updates to a new version of SQLite3. I have an idea for one possible solution: it could automatically compile extensions whenever better-sqlite3 is installed, for example, by searching for extensions in a special directory, like /sqlite3_extensions, which would sit next to your /node_modules directory. Obviously this would have limitations because you'd no longer have control over the actual compilation of your extensions.

I would like feedback from people who actually use extensions to better guide me towards making their experience the best possible (or, maybe it's fine as it is?). Any suggestions, comments, or concerns are welcome.

Add support for iterators and/or generators

I don't really know how this could be done, but using either all() or each() force the developer to basically iterate over the whole result set.

This could be a problem when dealing with very large amount of data.

It would be pretty nice if the statement implemented an iterator() method that returns an iterator that steps until it is done.

This would allow us to do things like

for (var row of stmt.iterator()) {
  // do stuff with the current row, why not even use
  // await inside an async function !
}

I am willing to try and implement it, but so far my (fuzzy) memories of C++ mean that this would probably be some time before seeing something even remotely useful.

Extend custom function

Would it be possible to extend Database.register with the following:

  1. pass extra parameter with user data
  2. attach Database and UserData to this when firing function callback?

Thanks!

Error: Could not locate the bindings file

Hi,
I installed better-sqlite3 without any issue.
But on : var Database = require('better-sqlite3') I have this error

win7 x64
electron 1.6.11
node 6.11.0
npm 3.10.10

App threw an error during load
Error: Could not locate the bindings file. Tried:
→ D:\project\nodeC\[email protected]@better-sqlite3\build\bett er_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\build\Debu g\better_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\build\Rele ase\better_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\out\Debug\ better_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\Debug\bett er_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\out\Releas e\better_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\Release\be tter_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\build\defa ult\better_sqlite3.node
→ D:\project\nodeC\[email protected]@better-sqlite3\compiled\7 .4.0\win32\x64\better_sqlite3.node
at bindings (D:\project\nodeC\node_modules_bindings@1.2.1@bindings\bindings .js:88:9)
at Object. (D:\project\nodeC\node_modules_better-sqlite3@3.1.1@b etter-sqlite3\lib\database.js:5:38)
at Object. (D:\project\nodeC\node_modules_better-sqlite3@3.1.1@b etter-sqlite3\lib\database.js:56:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)

Is it okay to remove compile flags?

Or does your plugin depend on them? For example out of -

SQLITE_ENABLE_FTS5
SQLITE_ENABLE_JSON1
SQLITE_ENABLE_RTREE
SQLITE_DEFAULT_CACHE_SIZE=-16000
SQLITE_DEFAULT_FOREIGN_KEYS=1
SQLITE_USE_URI=1
SQLITE_MAX_SCHEMA_RETRY=0

I really don't want - SQLITE_ENABLE_FTS5 & SQLITE_ENABLE_JSON1 so can I safely remove them? If yes, what would be the procedure of doing so? Or how about if I want to add some new compile time flags?

Win7 - Support

Win 7:

Command: npm install --save better-sqlite3

...fails with the following ouput...

674 verbose cwd C:\b\hello-electron-with-pouchdb
675 error Windows_NT 6.1.7601
676 error argv "C:\Program Files\nodejs\node.exe" "C:\Users\Stevie\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "--save" "better-sqlite3"
677 error node v4.6.0
678 error npm v3.10.8
679 error code ELIFECYCLE
680 error [email protected] install: node install
680 error Exit status 1
681 error Failed at the [email protected] install script 'node install'.
681 error Make sure you have the latest version of node.js and npm installed.
681 error If you do, this is most likely a problem with the better-sqlite3 package,
681 error not with npm itself.
681 error Tell the author that this fails on your system:
681 error node install
681 error You can get information on how to open an issue for this project with:
681 error npm bugs better-sqlite3
681 error Or if that isn't available, you can get their info via:
681 error npm owner ls better-sqlite3
681 error There is likely additional logging output above.
682 verbose exit [ 1, true ]

Do I miss some version-requirements?

please help

i downloaded with npm install --save better-sqlite3

but it keeps doing this and im not sure why

C:\scratch\Filmplicity\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Banana\AppData\Local\Programs\Python\Python36-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\scratch\Filmplicity\node_modules\better-sqlite3
gyp ERR! node -v v8.1.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Error: exit code 1
at ChildProcess. (C:\scratch\Filmplicity\node_modules\lzz-gyp\lib\exec.js:19:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node tools/install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Banana\AppData\Roaming\npm-cache_logs\2017-07-18T11_00_44_886Z-debug.log

C:\scratch\Filmplicity>

Install fails

Latest windows 10, using 'npm install --save better-sqlite3:

C:\Users\johnd\angular4\learn-rest> npm install --save better-sqlite3

[email protected] install C:\Users\johnd\angular4\learn-rest\node_modules\better-sqlite3
node tools/install

==> cwd: C:\Users\johnd\angular4\learn-rest\node_modules\better-sqlite3
==> C:\Users\johnd\angular4\learn-rest\node_modules\lzz-gyp\lzz-compiled\windows.exe -hx hpp -sx cpp -k BETTER_SQLITE3 -
d -hl -sl -e ./src/better_sqlite3.lzz
==> cwd: C:\Users\johnd\angular4\learn-rest\node_modules\better-sqlite3
==> node-gyp rebuild

C:\Users\johnd\angular4\learn-rest\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "C:\Program File
s\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuil
d )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\johnd\angular4\learn-rest\node_modules\better-sqlite3\build\deps\action_before_build.vcxproj(20,3): error MSB4
019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declara
tion is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:2
58:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\johnd\angular4\learn-rest\node_modules\better-sqlite3
gyp ERR! node -v v8.1.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Error: exit code 1
at ChildProcess. (C:\Users\johnd\angular4\learn-rest\node_modules\lzz-gyp\lib\exec.js:19:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node tools/install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\johnd\AppData\Roaming\npm-cache_logs\2017-07-13T09_52_20_212Z-debug.log
C:\Users\johnd\angular4\learn-rest>

Install problem (ubuntu 16.04 LTS)

Hi,
I wanted to try this module out, but I can't get it to install on my linux box. Problem seems buried in a compile step I can't see.

$ npm install better-sqlite3

> [email protected] install /home/OtterNet2/Otternet/node/node_modules/better-sqlite3
> node tools/install

==> cwd: /home/OtterNet2/Otternet/node/node_modules/better-sqlite3
==> /home/OtterNet2/Otternet/node/node_modules/better-sqlite3/node_modules/lzz-gyp/lzz-compiled/linux -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_sqlite3.lzz
/home/OtterNet2/Otternet/node/node_modules/better-sqlite3/node_modules/lzz-gyp/lzz-compiled/linux: 1: /home/OtterNet2/Otternet/node/node_modules/better-sqlite3/node_modules/lzz-gyp/lzz-compiled/linux: Syntax error: Unterminated quoted string
Error: exit code 2
    at ChildProcess.<anonymous> (/home/OtterNet2/Otternet/node/node_modules/better-sqlite3/node_modules/lzz-gyp/lib/exec.js:19:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)


Version information.

$ uname -a
Linux neutrino 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:27:09 UTC 2017 i686 i686 i686 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-5.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/5/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

Add support for setting SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE for database

In some cases, it is important to open a database only when a database file already exists and fail otherwise. But better-sqlite3 does not support it, even when database file does not exist, sqlite3 creates it (if the readonly option is not specified, of course). It will be great if you add a possibility to set these flags as options for database constructor alongside readonly flag.

Can #.open and #.close be executed synchronously?

Joshua, thanks for this great package.

Is there a design reason .open and .close are asynchronous? It seems these would fall under the same reasoning you made everything else synchronous, as you explain in the intro - or am I missing something?
cheers,

Inconsistent/Missing error codes vs node-sqlite3 (and node-sqlite)

Hi,

I noticed that the errors thrown from the module are not consistent with what one would expect being used with node-sqlite3, or in my case the Promise based version node-sqlite.

Here is an example that works in node-sqlite:

# insert a row that will trigger a `SQLITE_CONSTRAINT` error since it is duplicated data
db.run('INSERT [...]')
  .catch(e) {
    // we rely on the unique index for the id column so we don't have to check for existence beforehand
    // therefore just ignore if it's an SQLITE_CONSTRAINT
    if (e.code !== 'SQLITE_CONSTRAINT') {
      throw e;
    }
}

with better-sqlite3 I now have to do this (note how I have to do a string comparison because there is no error code in the error thrown by better-sqlite3:

try {
  db.prepare('INSERT [...]').run(params);
}
catch(e) {
   if (String(e).includes("SQLite: UNIQUE constraint failed") === -1) {
      throw e;
   }
}

Granted, my approach to handling duplicated IDs in the database is not necessarily the best. But there are cases where this approach is more efficient where we let the DB do its job (check existence of data for us).

Edit: I forgot to say thank you first of all for creating this module. It saved me quite a lot of white hairs :)

Return arrays?

In my case, I am most often taking the output of a query and mapping each row object to a different object. I think that in that case it would be more efficient to return rows as arrays in column order…

Add support for virtual tables

As said in the title.

Virtual tables are a pretty powerful feature of sqlite, would be incredibly nice to be able to use them in JS too !

Any ORM?

Hey,

I'm thinking about changing node-sqlite3 to better-sqlite3 but I use Sequelize and better-sqlite3 API is pretty different than node-sqlite3 API what makes it impossible.

Do you know any other ORM compatible with better-sqlite3?

Examples of Select (all, get etc)

I'm trying to port over some sqlite3 calls to better-sqlite3 and I could do with some basic examples of how to use .all and .get. I understand the prepared statement part but the syntax to make the call and process the return. This is an example from sqlite3:

this.db.all(SELECT name FROM sqlite_master WHERE type='table' AND name='${sqliteUtil.table(name)}';, function(err, rows) {
if(err) {
console.error(err);
return util.die('DB error at get');
}

next(null, rows.length === 1);

});

Empty buffer (aka new Buffer(0)) transforms to null instead of empty blob

const database  = require('better-sqlite3');
const db = new database('example.db');

db.on('open', () => {
  db.prepare('CREATE TABLE result(d BLOB, t integer);').run()

  const st = db.prepare('INSERT INTO result (d, t) VALUES (?, ?)')

  st.run([null, 1])
  st.run([new Buffer(0), 2])

  console.log('* in result:\n\t', db.prepare('SELECT * FROM result').all())

  console.log('SELECT d = null:\n\t', db.prepare('SELECT * FROM result WHERE d = ?').all(null))
  console.log('SELECT d = new Buffer(0):\n\t', db.prepare('SELECT * from result where d = ?').all(new Buffer(0)))
  console.log('SELECT d is new Buffer(0):\n\t', db.prepare('SELECT * from result where d is ?').all(new Buffer(0)))
  console.log('SELECT d is null:\n\t', db.prepare('SELECT * from result where d is ?').all(null))
});

output:

* in result:
     [ { d: null, t: 1 }, { d: null, t: 2 } ]
SELECT d = null:
     []
SELECT d = new Buffer(0):
     []
SELECT d is new Buffer(0):
     [ { d: null, t: 1 }, { d: null, t: 2 } ]
SELECT d is null:
     [ { d: null, t: 1 }, { d: null, t: 2 } ]

Worried about synchronicity

So, the entire API is synchronous, right?

So if you have a query that takes a while to run, say 0.5s-2s or so, that means the entire node process is hanging until the database returns?

Is that not problematic for web servers?

Would it be possible to have an asynchronous mode for queries that are expected to take a long time?

Trying to compile Nylas-n1

Hi,

I am trying to compile source code of another project, but the only errors I get are related to better-sqlite3. I tried googling the issue but could not find any result that would resolve this problem. Could anyone help me?

Running:
Windows 10
Node: v4.6.0
npm: v3.3.10
Python: 2.7.12

Thanks (alot) in advance.

Relevant log:
http://pastebin.com/mbUvpdHi

Support for Electron?

Hey! Was just checking out better-sqlite3. We currently use node-sqlite3 in https://github.com/nylas/N1 and are having a really obscure bug that we think is related to it's async implementation. Wanted to try switching to better-sqlite3, but I'm running into this issue building it against Electron 1.4.1. Any ideas?

export npm_config_target=1.4.1
# The architecture of Electron, can be ia32 or x64.
export npm_config_arch=x64
export npm_config_target_arch=x64
# Download headers for Electron.
export npm_config_disturl=https://atom.io/download/atom-shell
# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron
# Tell node-pre-gyp to build module from source code.
export npm_config_build_from_source=true
# Install all dependencies, and store cache to ~/.electron-gyp.
HOME=~/.electron-gyp npm install

npm install better-sqlite3

npm WARN prefer global [email protected] should be installed with -g

> [email protected] install /Users/bengotow/Nylas/N1/node_modules/better-sqlite3/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3090100/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3090100/sqlite3.o
Release/obj/gen/sqlite-autoconf-3090100/sqlite3.c:9704:26: warning: unused variable 'sqlite3one' [-Wunused-const-variable]
SQLITE_PRIVATE const int sqlite3one = 1;
                         ^
1 warning generated.
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
../src/database.cc:132:18: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
    info.This()->ForceSet(Nan::New("filename").ToLocalChecked(), info[0].As<String>(), ReadOnly);
                 ^
/Users/bengotow/.node-gyp/iojs-1.4.1/deps/v8/include/v8.h:2702:22: note: 'ForceSet' has been explicitly marked deprecated here
                bool ForceSet(Local<Value> key, Local<Value> value,
                     ^
../src/database.cc:133:18: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
    info.This()->ForceSet(Nan::New("mode").ToLocalChecked(), Nan::New(mode), ReadOnly);
                 ^
/Users/bengotow/.node-gyp/iojs-1.4.1/deps/v8/include/v8.h:2702:22: note: 'ForceSet' has been explicitly marked deprecated here
                bool ForceSet(Local<Value> key, Local<Value> value,
                     ^
../src/database.cc:143:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/database.cc:227:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/database.cc:505:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/database.cc:605:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
6 warnings generated.
  CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
  CXX(target) Release/obj.target/node_sqlite3/src/statement.o
../src/statement.cc:103:18: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
    info.This()->ForceSet(Nan::New("sql").ToLocalChecked(), sql, ReadOnly);
                 ^
/Users/bengotow/.node-gyp/iojs-1.4.1/deps/v8/include/v8.h:2702:22: note: 'ForceSet' has been explicitly marked deprecated here
                bool ForceSet(Local<Value> key, Local<Value> value,
                     ^
../src/statement.cc:118:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/statement.cc:322:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Bind);
    ^
../src/macros.h:125:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = uv_queue_work(uv_default_loop(),                              \
        ^
../src/statement.cc:370:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Get);
    ^
../src/macros.h:125:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = uv_queue_work(uv_default_loop(),                              \
        ^
../src/statement.cc:438:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Run);
    ^
../src/macros.h:125:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = uv_queue_work(uv_default_loop(),                              \
        ^
../src/statement.cc:504:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(All);
    ^
../src/macros.h:125:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = uv_queue_work(uv_default_loop(),                              \
        ^
../src/statement.cc:601:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Each);
    ^
../src/macros.h:125:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = uv_queue_work(uv_default_loop(),                              \
        ^
../src/statement.cc:724:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Reset);
    ^
../src/macros.h:125:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = uv_queue_work(uv_default_loop(),                              \
        ^
8 warnings generated.
  SOLINK_MODULE(target) Release/node_sqlite3.node
  COPY /Users/bengotow/Nylas/N1/node_modules/better-sqlite3/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node
  TOUCH Release/obj.target/action_after_build.stamp

> [email protected] install /Users/bengotow/Nylas/N1/node_modules/better-sqlite3
> if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;

  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3140100/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3140100/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/better_sqlite3/src/objects/int64/int64.o
  CXX(target) Release/obj.target/better_sqlite3/src/util/data.o
  CXX(target) Release/obj.target/better_sqlite3/src/objects/database/database.o
  CXX(target) Release/obj.target/better_sqlite3/src/objects/statement/statement.o
In file included from ../src/objects/statement/statement.cc:20:
../src/objects/statement/util.cc:11:48: error: no member named 'GetHiddenValue' in 'v8::Object'
                return v8::Local<v8::Object>::Cast(handle()->GetHiddenValue(Nan::EmptyString()));
                                                   ~~~~~~~~  ^
../src/objects/statement/util.cc:23:13: error: no member named 'SetHiddenValue' in 'v8::Object'
                handle()->SetHiddenValue(Nan::EmptyString(), namedParams);
                ~~~~~~~~  ^
2 errors generated.
make: *** [Release/obj.target/better_sqlite3/src/objects/statement/statement.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/bengotow/.nvm/versions/node/v6.2.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/Users/bengotow/.nvm/versions/node/v6.2.2/bin/node" "/Users/bengotow/.nvm/versions/node/v6.2.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/bengotow/Nylas/N1/node_modules/better-sqlite3
gyp ERR! node -v v6.2.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 

Server Usage

Hi Bro,
This isnt an issue more of a question with regards to better-sqlite3

how many connections can be used for example we have a server which around 3000 clients talk to we were using mysql but the npm modules are shit you cannot query before inserting which causes alot of issues as for your sqlite we can and the speed is amazing.

the sever handles the clients with sockets.io so the question is will the module be able to handle multiple inserts from the server? and reads without opening and closing the dbs? (connections?)

Cannot Install better-sqlite3 on Raspberry PI via npm install command.

pi@raspi:~/betterbusinesszimbabwe $ npm install --save better-sqlite3

[email protected] install /home/pi/betterbusinesszimbabwe/node_modules/integer
node tools/install

make: Entering directory '/home/pi/betterbusinesszimbabwe/node_modules/integer/build'
CXX(target) Release/obj.target/integer/src/integer.o
SOLINK_MODULE(target) Release/obj.target/integer.node
COPY Release/integer.node
make: Leaving directory '/home/pi/betterbusinesszimbabwe/node_modules/integer/build'

[email protected] install /home/pi/betterbusinesszimbabwe/node_modules/better-sqlite3
node tools/install

==> cwd: /home/pi/betterbusinesszimbabwe/node_modules/better-sqlite3
==> /home/pi/betterbusinesszimbabwe/node_modules/lzz-gyp/lzz-compiled/linux -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_sqlite3.lzz
/home/pi/betterbusinesszimbabwe/node_modules/lzz-gyp/lzz-compiled/linux: 1: /home/pi/betterbusinesszimbabwe/node_modules/lzz-gyp/lzz-compiled/linux: Syntax error: Unterminated quoted string
Error: exit code 2
at ChildProcess. (/home/pi/betterbusinesszimbabwe/node_modules/lzz-gyp/lib/exec.js:19:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
npm WARN [email protected] requires a peer of extract-text-webpack-plugin@>=2.1.0 but none was installed.
npm WARN [email protected] requires a peer of webpack@>=2.2.0 but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] No repository field.

Cannot run benchmarks

This error occurs on executing node benchmark -

root@cpp-workspace:~/better-sqlite3# node benchmark/
Generating tables...
/root/better-sqlite3/node_modules/bindings/bindings.js:91
  throw err
  ^

Error: Could not locate the bindings file. Tried:
 → /root/better-sqlite3/build/better_sqlite3.node
 → /root/better-sqlite3/build/Debug/better_sqlite3.node
 → /root/better-sqlite3/build/Release/better_sqlite3.node
 → /root/better-sqlite3/out/Debug/better_sqlite3.node
 → /root/better-sqlite3/Debug/better_sqlite3.node
 → /root/better-sqlite3/out/Release/better_sqlite3.node
 → /root/better-sqlite3/Release/better_sqlite3.node
 → /root/better-sqlite3/build/default/better_sqlite3.node
 → /root/better-sqlite3/compiled/6.10.0/linux/x64/better_sqlite3.node
    at bindings (/root/better-sqlite3/node_modules/bindings/bindings.js:88:9)
    at Object.<anonymous> (/root/better-sqlite3/lib/database.js:4:38)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/root/better-sqlite3/index.js:2:18)

Also on running npm install something came up as well -

npm install

> [email protected] install /root/better-sqlite3/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

[sqlite3] Success: "/root/better-sqlite3/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node" is installed via remote

npm WARN lifecycle [email protected]~install: cannot run in wd %s %s (wd=%s) [email protected] node install /root/better-sqlite3

Raspbian Support

Hi, my env is raspbian jessie on Raspberry Pi 3

npm install failed:

[email protected] install /home/tomjamescn/proxy-ng/node_modules/better-sqlite3
node tools/install

==> cwd: /home/tomjamescn/proxy-ng/node_modules/better-sqlite3
==> /home/tomjamescn/proxy-ng/node_modules/lzz-gyp/lzz-compiled/linux -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_sqlite3.lzz
/home/tomjamescn/proxy-ng/node_modules/lzz-gyp/lzz-compiled/linux: 1: /home/tomjamescn/proxy-ng/node_modules/lzz-gyp/lzz-compiled/linux: Syntax error: Unterminated quoted string
Error: exit code 2
at ChildProcess. (/home/tomjamescn/proxy-ng/node_modules/lzz-gyp/lib/exec.js:19:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
npm WARN [email protected] No description
npm ERR! Linux 4.4.34-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node tools/install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node tools/install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the better-sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node tools/install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs better-sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls better-sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/tomjamescn/proxy-ng/npm-debug.log

Support for Electron on Win7?

Win7:

C:\0000_TRANSFER\HTML5\webpackprojectfinal>npm install --save better-sqlite3 >>infoA.txt
"$CI" was unexpected at this time.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"
})
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Stevie\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "--save" "better-sq
lite3"
npm ERR! node v4.5.0
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the better-sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs better-sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls better-sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\0000_TRANSFER\HTML5\webpackprojectfinal\npm-debug.log

npm-debug.log (seems I'm to silly)
[...]

536 silly gunzTarPerm extractEntry src/util/list.h
537 silly gunzTarPerm extractEntry src/util/macros.h
538 silly gunzTarPerm extractEntry src/util/strlcpy.h
539 silly gunzTarPerm extractEntry src/util/transaction-handles.h
540 silly gunzTarPerm extractEntry src/workers/close.cc
541 silly gunzTarPerm extractEntry src/workers/close.h
542 silly gunzTarPerm extractEntry src/workers/open.cc
543 silly gunzTarPerm extractEntry src/workers/open.h
544 silly gunzTarPerm extractEntry binding.gyp
545 silly gentlyRm C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\better-sqlite3-555b5ef6\node_modules is being purged
546 verbose gentlyRm don't care about contents; nuking C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\better-sqlite3-555b5ef6\node_modules
547 silly doParallel preinstall 4
548 silly preinstall [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\bindings-11c74a77
549 info lifecycle [email protected]preinstall: [email protected]
550 silly preinstall [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\nan-7d0e32d4
551 info lifecycle [email protected]
preinstall: [email protected]
552 silly preinstall [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\to-descriptor-697cf33b
553 info lifecycle [email protected]preinstall: [email protected]
554 silly preinstall [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\better-sqlite3-555b5ef6
555 info lifecycle [email protected]
preinstall: [email protected]
556 silly lifecycle [email protected]preinstall: no script for preinstall, continuing
557 silly lifecycle [email protected]
preinstall: no script for preinstall, continuing
558 silly lifecycle [email protected]preinstall: no script for preinstall, continuing
559 silly lifecycle [email protected]
preinstall: no script for preinstall, continuing
560 silly doReverseSerial remove 0
561 silly doSerial move 0
562 silly doSerial finalize 4
563 silly finalize C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules\bindings
564 silly finalize C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules\nan
565 silly finalize C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules\to-descriptor
566 silly finalize C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules\better-sqlite3
567 silly doSerial build 4
568 silly build [email protected]
569 info linkStuff [email protected]
570 silly linkStuff [email protected] has C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules as its parent node_modules
571 verbose linkBins [email protected]
572 verbose linkMans [email protected]
573 silly build [email protected]
574 info linkStuff [email protected]
575 silly linkStuff [email protected] has C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules as its parent node_modules
576 verbose linkBins [email protected]
577 verbose linkMans [email protected]
578 silly build [email protected]
579 info linkStuff [email protected]
580 silly linkStuff [email protected] has C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules as its parent node_modules
581 verbose linkBins [email protected]
582 verbose linkMans [email protected]
583 silly build [email protected]
584 info linkStuff [email protected]
585 silly linkStuff [email protected] has C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules as its parent node_modules
586 verbose linkBins [email protected]
587 verbose linkMans [email protected]
588 silly doSerial global-link 0
589 silly doParallel update-linked 0
590 silly doSerial install 4
591 silly install [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\bindings-11c74a77
592 info lifecycle [email protected]install: [email protected]
593 silly lifecycle [email protected]
install: no script for install, continuing
594 silly install [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\nan-7d0e32d4
595 info lifecycle [email protected]install: [email protected]
596 silly lifecycle [email protected]
install: no script for install, continuing
597 silly install [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\to-descriptor-697cf33b
598 info lifecycle [email protected]install: [email protected]
599 silly lifecycle [email protected]
install: no script for install, continuing
600 silly install [email protected] C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging\better-sqlite3-555b5ef6
601 info lifecycle [email protected]install: [email protected]
602 verbose lifecycle [email protected]
install: unsafe-perm in lifecycle true
603 verbose lifecycle [email protected]install: PATH: C:\Users\Stevie\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules\better-sqlite3\node_modules.bin;C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.bin;C:\Program Files\MSBuild\12.0\Bin;C:\Ruby23-x64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Common Files\Autodesk Shared;C:\Program Files (x86)\Autodesk\Backburner;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files\nodejs;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\Git\cmd;C:\Python27;G:\Android;G:\Android\platform-tools;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Stevie\AppData\Roaming\npm;C:\Program Files\Java\jdk1.8.0_101\bin;C:\Users\Stevie\ant\bin
604 verbose lifecycle [email protected]
install: CWD: C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules\better-sqlite3
605 silly lifecycle [email protected]install: Args: [ '/d /s /c',
605 silly lifecycle 'if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;' ]
606 silly lifecycle [email protected]
install: Returned: code: 1 signal: null
607 info lifecycle [email protected]~install: Failed to exec install script
608 verbose unlock done using C:\Users\Stevie\AppData\Roaming\npm-cache_locks\staging-3580680f365b1985.lock for C:\0000_TRANSFER\HTML5\webpackprojectfinal\node_modules.staging
609 silly rollbackFailedOptional Starting
610 silly rollbackFailedOptional Finishing
611 silly runTopLevelLifecycles Finishing
612 silly install printInstalled
613 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
614 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
615 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
615 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
615 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32
615 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
616 verbose stack Error: [email protected] install: if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;
616 verbose stack Exit status 1
616 verbose stack at EventEmitter. (C:\Users\Stevie\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:255:16)
616 verbose stack at emitTwo (events.js:87:13)
616 verbose stack at EventEmitter.emit (events.js:172:7)
616 verbose stack at ChildProcess. (C:\Users\Stevie\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
616 verbose stack at emitTwo (events.js:87:13)
616 verbose stack at ChildProcess.emit (events.js:172:7)
616 verbose stack at maybeClose (internal/child_process.js:829:16)
616 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
617 verbose pkgid [email protected]
618 verbose cwd C:\0000_TRANSFER\HTML5\webpackprojectfinal
619 error Windows_NT 6.1.7601
620 error argv "C:\Program Files\nodejs\node.exe" "C:\Users\Stevie\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "--save" "better-sqlite3"
621 error node v4.5.0
622 error npm v3.10.8
623 error code ELIFECYCLE
624 error [email protected] install: if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;
624 error Exit status 1
625 error Failed at the [email protected] install script 'if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;'.
625 error Make sure you have the latest version of node.js and npm installed.
625 error If you do, this is most likely a problem with the better-sqlite3 package,
625 error not with npm itself.
625 error Tell the author that this fails on your system:
625 error if [ "$CI" = "true" ]; then node-gyp rebuild --debug; else node-gyp rebuild; fi;
625 error You can get information on how to open an issue for this project with:
625 error npm bugs better-sqlite3
625 error Or if that isn't available, you can get their info via:
625 error npm owner ls better-sqlite3
625 error There is likely additional logging output above.
626 verbose exit [ 1, true ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.