GithubHelp home page GithubHelp logo

orlandov / node-sqlite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grumdrig/node-sqlite

262.0 11.0 29.0 2.29 MB

Asynchronous, non-blocking SQLite3 bindings for Node.js

C 98.27% C++ 0.85% Ruby 0.02% Shell 0.01% JavaScript 0.87%

node-sqlite's Introduction

NAME

node-sqlite - Asynchronous SQLite3 driver for Node.js

SQLite calls block, so to work around this, synchronous calls happen within Node's libeio thread-pool, in a similar manner to how POSIX calls are currently made.

SYNOPSIS

High-level Driver

var sys    = require('sys'),
    sqlite = require('sqlite');

var db = new sqlite.Database();

// open the database for reading if file exists
// create new database file if not

db.open("aquateen.db", function (error) {
  if (error) {
      console.log("Tonight. You."));
      throw error;
  }
  db.execute
    ( "INSERT INTO aqua_teens (name) VALUES (?)"
    , ['meaty meaty moo']
    , function (error, rows) {
        if (error) throw error;
        console.log("Aqua teen added.");
      }
    );
  var sql = 'SELECT name FROM dudes WHERE type = ? AND age > ?';

  db.prepare(sql, function (error, statement) {
    if (error) throw error;

    // Fill in the placeholders
    statement.bindArray(['milkshake', 30], function () {

      statement.fetchAll(function (error, rows) {
        // ...
        statement.finalize(function (error) {
          console.log("All done!");
        });
      });
    });
  });
});

API

Database Objects

To create a new database object: var sqlite = require('sqlite');

var db = sqlite.Database();

database.open(filename, function (error) {})

Open a database handle to the database at the specified filename. If the file does not exist the bindings will attempt to create it. The callback takes no arguments.

A filename of ":memory:" may be used to create an in-memory database.

database.close(function (error) {})

Close the database handle.

database.execute(sql[, bindings], function (error, rows) {})

Execute a SQL query, sql with optional bindings bindings on the currently opened database. The callback will be executed once with all the rows returned for the query. This is much faster than database.query since there are less roundtrips into the thread-pool.

database.query(sql, [bindings,] function (error, row) {})

Execute a SQL query, sql, with optional bindings bindings on the currently opened database. The callback will be executed once per row returned, plus once more with row set to undefined to indicate end of results.

database.executeScript(SQL, function (error) {});

db.executeScript
  (   "CREATE TABLE table1 (id, name);"
    + "CREATE TABLE table2 (id, age);"
    + "INSERT INTO table1 (1, 'Mister Shake');"
    + "INSER INTO table2 (1, 34);"
  , function (error) {
      if (error) throw error;
      // ...
    });

Execute multiple semi-colon separated SQL statements. Statements must take no placeholders. Each statement will be executed with a single step() and then reset. This is ideally suited to executing multiple DDL statements.

database.prepare(SQL, [options,] function (error, statement) {})

Create a prepared statement from an SQL string. Prepared statements can be used used to iterate over results and to avoid compiling SQL each time a query is performed.

Options:

  • lastInsertRowID: boolean, default false. If true, when this statement is step()'d over, the context object (this) in the callback will contain a lastInsertRowID member with the ID of the last inserted row.

  • affectedRows: boolean, default false. If true, when this statement is step()'d over, the context object (this) in the callback will contain an affectedRows member with the number of affected rows for the last step.

Statement Objects

statement.bindArray(array, function (error) {})

statement.bindArray([1, 'robots', 4.20], callback)

Bind array items to place-holder values (? or $foo) in statement.

statement.bindObject(object, function (error) {})

statement.bindObject({ $name: 'meatwad',
                       $occupation: 'Former detective' }, callback)

Bind object properties to named place-holder values ($foo, $bar, $baz) in statement.

statement.bind(position, value, function (error) {})

statement.bind(1, "tango", function (error) {})

Bind a value to a place-holder position. Because binding place-holders is done by position (not index), the first place-holder is at position 1, second at place-holder position 2, etc.

statement.clearBindings()

Immediately clear the bindings from the statement. There is no callback.

statement.step(function (error, row) {})

Fetch one row from a prepared statement and hand it off to a callback. If there are no more rows to be fetched, row will be undefined. Rows are represented as objects with properties named after the respective columns.

statement.fetchAll(function (error, rows) {})

Fetch all rows in statement and pass them to the callback as an array of objects, each object representing one row.

statement.reset()

Immediately reset a statement object back to it's initial state, ready to be step() or fetchAll()'d again.

statement.finalize(function (error) {})

Free SQLite objects associated with this statement and mark it for garbage collection.

Supported Types

At the moment, the supported types are TEXT, NUMBER, FLOAT and NULL.

BUILDING

To obtain and build the bindings:

git clone http://github.com/orlandov/node-sqlite.git
cd node-sqlite
node-waf configure build

TESTS

Running the unit tests could not be easier. Simply:

git submodule update --init
./run-tests

SEE ALSO

AUTHORS

Orlando Vazquez [[email protected]]

Ryan Dahl [[email protected]]

THANKS

Many thanks to Eric Fredricksen for his synchronous driver on which this driver was originally based.

LICENSE

node-sqlite is BSD licensed.

(c) 2010 Orlando Vazquez

node-sqlite's People

Contributors

grumdrig avatar mrjjwright avatar orlandov avatar ry 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

node-sqlite's Issues

`close()` doesn't work.

the callback passed to close almost inevitably gets passed an error object. unfortunately, the sqlite result code is not attached, so it's hard to guess at why.

I've hacked some printfs into the close routines and it seems that the returned error is always 5-> SQLITE_BUSY which is mentioned in the man page for close: "If sqlite3_close() is called on a database connection that still has outstanding prepared statements or BLOB handles, then it returns SQLITE_BUSY."

I'm afraid my c++ isn't too hot, but it seems that sqlite3_finalize is never called on the prepared statement handle in the case of Prepare (PrepareAndStep does call finalize)

Steps to reproduce:
If the tests are changed to log an error in the close callback, none of the tests are able to close without error. ( not sure how to attach a patch here, and I'm not sure if it makes sense to...)

node-waf build Error

I am using Ubuntu 11.10 , node-waf configure has no issue but build throws this error

Waf: Entering directory /home/anand/Downloads/node-sqlite/build' [1/2] cxx: sqlite3_bindings.cc -> build/Release/sqlite3_bindings_1.o ../sqlite3_bindings.cc:19:25: fatal error: node_events.h: No such file or directory compilation terminated. Waf: Leaving directory/home/anand/Downloads/node-sqlite/build'
Build failed: -> task failed (err #1):
{task: cxx sqlite3_bindings.cc -> sqlite3_bindings_1.o}

Non-NULL zero-length strings cause a crash

statement.cc, line 507, asserts that the text coming out of sqlite have a non-zero length.
This is not always the case. NULL and the empty string are considered different values.
I've simply commented out the assertion locally, and this fixes the problem.

    case SQLITE_TEXT:
      assert(strlen((char*)sto->column_data_[i]));            //  <-----  broken
      row->Set(String::NewSymbol(sto->column_names_[i]),
               String::New((char *) (sto->column_data_[i])));

it doesn't work

    node.js:194
            throw e; // process.nextTick error, or 'error' event on first tick
                  ^
    Error: dlopen(/Users/dustin/workspace/twt/node_modules/sqlite/build/default/sqlite3_bindings.node, 1): Symbol not found: __ZN4node12EventEmitter20constructor_templateE
      Referenced from: /Users/dustin/workspace/twt/node_modules/sqlite/build/default/sqlite3_bindings.node
      Expected in: flat namespace
     in /Users/dustin/workspace/twt/node_modules/sqlite/build/default/sqlite3_bindings.node
        at Object..node (module.js:465:11)
        at Module.load (module.js:335:31)
        at Function._load (module.js:294:12)
        at Module.require (module.js:341:17)
        at require (module.js:352:17)
        at Object.<anonymous> (/Users/dustin/workspace/twt/node_modules/sqlite/sqlite.js:19:14)
        at Module._compile (module.js:420:26)
        at Object..js (module.js:459:10)
        at Module.load (module.js:335:31)
        at Function._load (module.js:294:12)

$ node -v
v0.5.3-pre

sqlite v 1.0.4

errors on ubuntu server 10.10

Running require('sqlite') throws up an error:

Error: /home/ubuntu/.node_libraries/.npm/sqlite/0.0.6/package/sqlite3_bindings.node: undefined symbol: ev_default_loop_ptr
    at Module._loadObjectSync (node.js:360:13)
    at Module.loadSync (node.js:336:12)
    at loadModule (node.js:283:14)
    at require (node.js:411:14)
    at Object.<anonymous> (/home/ubuntu/.node_libraries/.npm/sqlite/0.0.6/package/sqlite.js:19:14)
    at Module._compile (node.js:462:23)
    at Module._loadScriptSync (node.js:469:10)
    at Module.loadSync (node.js:338:12)
    at loadModule (node.js:283:14)
    at require (node.js:412:14)

Escaping

It would be nice if you provided a function to escape sql statements.

npm package.json errors

I'm using node 0.4.1 with npm 0.3.9. When I try to install sqlite via npm I get the following error:

$ npm install sqlite
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/sqlite/-/sqlite-1.0.2.tgz
npm info calculating sha1 /var/folders/Es/EsMnDChmE+qahsDMbT+IMk+++TI/-Tmp-/npm-1298838692411/1298838692411-0.7790314091835171/tmp.tgz
npm info shasum d0d2c234d3ffe2dcca2fcffb1709d12b02aa325c
npm ERR! couldn't read package.json in /var/folders/Es/EsMnDChmE+qahsDMbT+IMk+++TI/-Tmp-/npm-1298838692411/1298838692411-0.7790314091835171/contents/package
npm ERR! Error installing [email protected]
npm ERR! Error: Failed to parse json
npm ERR! Unexpected token ILLEGAL
npm ERR!     at jsonParseFail (/Users/zef/.node_libraries/.npm/npm/0.3.9/package/lib/utils/read-json.js:89:11)
npm ERR!     at /Users/zef/.node_libraries/.npm/npm/0.3.9/package/lib/utils/read-json.js:82:14
npm ERR!     at P (/Users/zef/.node_libraries/.npm/npm/0.3.9/package/lib/utils/read-json.js:62:40)
npm ERR!     at cb (/Users/zef/.node_libraries/.npm/npm/0.3.9/package/lib/utils/graceful-fs.js:31:9)
npm ERR!     at [object Object].<anonymous> (fs.js:86:5)
npm ERR!     at [object Object].emit (events.js:39:17)
npm ERR!     at afterRead (fs.js:843:12)
npm ERR! JSON.parse 
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse Note that package.json must be actual JSON, not
npm ERR! JSON.parse just a JavaScript object.
npm ERR! JSON.parse 
npm ERR! JSON.parse This changed in npm 0.3.0, and is not a bug in npm.
npm ERR! JSON.parse Tell the package author to fix their package.json file.
npm ERR! JSON.parse
npm ERR! System Darwin 10.6.0

Install fails for Node v0.6.x

Hi Orlando and contributin' folks,

I'm using npm 1.0.104 and the n utility to switch versions of Node. I can install the sqlite module using Node v0.4.x, but not v0.6.x. with v0.6.x I get a long gory dump, as shown below:

[3/6] cxx: src/database.cc -> build/Release/src/database_2.o ../src/database.cc: In static member function ‘static v8::Handlev8::Value Database::Open(const v8::Arguments&)’: ../src/database.cc:137: error: invalid conversion from ‘int (_)(eio_req_)’ to ‘void (_)(eio_req_)’ ../src/database.cc:137: error: initializing argument 1 of ‘eio_req\* eio_custom(void (_)(eio_req_), int, int (_)(eio_req_), void_)’ ../src/database.cc: In static member function ‘static v8::Handlev8::Value Database::Close(const v8::Arguments&)’: ../src/database.cc:202: error: invalid conversion from ‘int (_)(eio_req_)’ to ‘void (_)(eio_req_)’ ../src/database.cc:202: error: initializing argument 1 of ‘eio_req_ eio_custom(void (_)(eio_req_), int, int (_)(eio_req_), void_)’ ../src/database.cc: In static member function ‘static v8::Handlev8::Value Database::PrepareAndStep(const v8::Arguments&)’: ../src/database.cc:370: error: invalid conversion from ‘int (_)(eio_req_)’ to ‘void (_)(eio_req_)’ ../src/database.cc:370: error: initializing argument 1 of ‘eio_req_ eio_custom(void (_)(eio_req_), int, int (_)(eio_req_), void_)’ ../src/database.cc: In static member function ‘static v8::Handlev8::Value Database::Prepare(const v8::Arguments&)’: ../src/database.cc:506: error: invalid conversion from ‘int (_)(eio_req_)’ to ‘void (_)(eio_req_)’ ../src/database.cc:506: error: initializing argument 1 of ‘eio_req_ eio_custom(void (_)(eio_req_), int, int (_)(eio_req_), void*)’ ../deps/sqlite/sqlite3.c: In function ‘proxyGetHostID’: ../deps/sqlite/sqlite3.c:28396: warning: unused variable ‘timeout’ Waf: Leaving directory `/Users/mike/node_modules/sqlite/build' Build failed: -> task failed (err #1): {task: cxx database.cc -> database_2.o} npm ERR! error installing [email protected] Error: [email protected] preinstall:`node-waf configure build` npm ERR! error installing [email protected]`sh "-c" "node-waf configure build"`failed with 1 npm ERR! error installing [email protected] at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20) npm ERR! error installing [email protected] at ChildProcess.emit (events.js:70:17) npm ERR! error installing [email protected] at maybeExit (child_process.js:359:16) npm ERR! error installing [email protected] at Process.onexit (child_process.js:395:5) npm ERR! [email protected] preinstall:`node-waf configure build` npm ERR!`sh "-c" "node-waf configure build"` failed with 1 npm ERR! npm ERR! Failed at the [email protected] preinstall script. npm ERR! This is most likely a problem with the sqlite package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-waf configure build npm ERR! You can get their info via: npm ERR! npm owner ls sqlite npm ERR! There is likely additional logging output above. npm ERR! npm ERR! System Darwin 10.6.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "sqlite" npm ERR! cwd /Users/mike/tmp/sqlite npm ERR! node -v v0.6.6 npm ERR! npm -v 1.0.104 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/mike/tmp/sqlite/npm-debug.log npm not ok

Elven rock,
Mike

Why the assert(db_ == NULL); statement is there? and what will happen if I removed it ?

The first question is in the title.

The second question I am writing a backend for a website and uses your module for sqlite stuff.
For each request I open a variable database file(using the same handle for all the server) but when there is multiple requests comes after each other the server hangs and prints that exception.
Error: Error closing database
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'out of memory' }
Why that happens despite for each open call there is a corresponding end call, I have no idea why that happens ?

Teeensy additional bits of documentation?

How to install:

$ node-waf configure
$ node-waf build

This took me about 15 minutes to figure out, though it might be an obvious idiom to people using node stuff day to day.

How to run test? Which tests to run?

running:

for i in tests/*.js; do
    node $i
done

leads to the error:

/home/a2800276/projects/node/sqlite/node-sqlite-async/tests/test2.js:78
      if (error) throw (error);  
                  ^
Error: no such table: foo
at node.js:204:9

I can't tell whether I'm not executing the test properly, or something is broken :(

Transactions?

I'm experiencing very low INSERT performance. http://www.sqlite.org/speed.html advises to use transactions.

db.query("BEGIN; INSERT ...; INSERT ...; INSERT ...; COMMIT;", [], function() { }); doesn't work. Passing the SQL queries as individual serial queries doesn't work either. Any alternative to query()?

Precompiled binary files for windows...

Would be nice if you added precompiled win-x86/win-x64 binaries, and had the install script simply copy the correct one... having a build environment on a production windows server is problematic, and the fact the "global" install on npm for windows is per-user makes it even more of a pain...

In general, really like what you have done... just feel that including pre-built binaries for windows (which isn't as hard as various *nix environments) would be a good call... alternatively, have the install script download the correct driver if it is a windows environment.

I get wrong values from the database when using node-sqlite

I have a table column where I store large numbers (seconds since 1970).

The bigints are stored correctly (I checked it on the sqlite console) but with the sqlite driver I get negative(!) values. What's wrong here?

sqlite3 console:
sqlite> SELECT date FROM seen WHERE user='root' COLLATE NOCASE;
1296333940003

node-sqlite:
{ date: -746187876 }

I also tried "BIGINT UNSIGNED" with the same (wrong) result.

synchronous form?

Hi,

The work you've done on the async sqlite library is exciting. I have (what I think are good) reasons to want a synchronous call style as well...so in node convention, *Sync forms of methods like execute (executeSync).

I'd love to see this implemented in your fork - I think that would do something to unify the (slightly crazy) node-sqlite world (grumdrig's is broken on node v.3.0 and above).

I'd fork and do this myself but it's been soooo long since I did any cpp that I'd rather leave it to more experienced cpp developers.

Is sync support on the roadmap? Is there any prospect of it getting in anytime soon?

Regards,
Steve

npm install fails with npm version 0.2.16

When running npm install I see "Nothing to clean (project not configured)" followed by "Tell the author that this fails on your system: node-waf clean configure build".

node-waf clean configure build runs just fine (exit code 0).

echo "def clean(conf): pass" >> wscript allows npm install to complete without errors. however the installation is not valid.

require('sqlite')
Error: Cannot find module './sqlite3_bindings'

Inspecting '/home/steven/.local/lib/node/.npm/sqlite/0.0.6/package' reveals that 'sqlite3_bindings.node' is indeed missing (it is located in ./build/default however ..).

bash build.sh error node-waf

Hello, I'm running bash build.sh And I get a message: command not found: node-waf
Are there any other ways of assembling?

Why the assert(db_ == NULL); statement is there? and what will happen if I removed it ?

The first question is in the title.

The second question I am writing a backend for a website and uses your module for sqlite stuff.
For each request I open a variable database file(using the same handle for all the server) but when there is multiple requests comes after each other the server hangs and prints that exception.
Error: Error closing database
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'out of memory' }
Why that happens despite for each open call there is a corresponding end call, I have no idea why that happens ?

Text variable bindings appear to work, but then can't be used in WHERE clauses!

Execute some SQL like this, using the node-sqlite library:
INSERT INTO tbl (foo) VALUES (?)
and use a string bind value, like ['abc']

For example:
db.query("INSERT INTO tbl (foo) VALUES (?)", ['abc'], function() {});

If you open up a sqlite3 console, you'll see your new row. Yet the following query will return no rows:
SELECT * FROM tbl WHERE foo = 'abc'

You can see them right there. What's wrong?

After a good deal of debugging time, I found the culprit.

In statement.cc, the various Bind, BindArray, BindObjects, store value_size as the total C string length, including the NUL terminator.

For example, around line 200, there is:
else if (val->IsString()) {
pairs->value_type = VALUE_STRING;
String::Utf8Value text(val);
char value = (char *) calloc(text.length()+1, sizeof(char));
strcpy(value, *text);
pairs->value = value;
pairs->value_size = text.length()+1; // <---- right here
}

Then in EIO_BindArray, around line 133:

  case VALUE_STRING:
    rc = sqlite3_bind_text(sto->stmt_, index, (char*)(pair->value),
        pair->value_size, SQLITE_TRANSIENT);       //  <---  value_size
    break;

I just changed it to use:
pair->value_size-1, SQLITE_TRANSIENT);

and everything works great!

On query, the values are NUL-terminated again while converting to JS strings. I noticed that all of your tests simply ensure that the text binds come back via a SELECT, which wouldn't catch this.

The sqlite3 documentation isn't very good at describing the 'n' parameter to sqlite3_bind_text().
I guess we just found out the hard way that it shouldn't include any terminators.

I tried a few UTF-8 Japanese strings, empty strings, null, etc, and they all work great with this change.

Hope this helps!

  • Carter

Documentation is wrong

The documentation says that the row is passed as the 1st argument:
db.query(sql, [colour], function (pony) { ... });

Where as in the node.js code it's passed as 2nd:
rowCallback(undefined, row);

Very annoying.

missing node_events.h

Compiling against Node 0.6.4, I get this error:

In file included from ../src/statement.cc:23: ../src/database.h:22:25: error: node_events.h: No such file or directory ../src/database.cc:20:25: error: node_events.h: No such file or directory ../src/sqlite3_bindings.cc:19:25: error: node_events.h: No such file or directory

It seems other projects have seen the problem as well:
node-pcap/node_pcap#34

Does Not Build on OS X

It does not build on OS X. I installed the latest Node.js using Homebrew.
Checked node-sqlite out of GitHub and ran the following.

[alan@postojna node-sqlite]$ node-waf configure build
Checking for program g++ or c++          : /usr/bin/g++
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok
Checking for node path                   : not found
Checking for node prefix                 : ok /opt/Cellar/node/0.1.103
Checking for sqlite3                     : not found
Checking for library sqlite3             : yes
'configure' finished successfully (0.419s)
Waf: Entering directory `/Users/alan/git/synapse/node-sqlite/build'
[1/4] cxx: src/sqlite3_bindings.cc -> build/default/src/sqlite3_bindings_1.o
[2/4] cxx: src/database.cc -> build/default/src/database_1.o
../src/database.h:95: error: ‘sqlite3_int64’ does not name a type
../src/database.h:95: error: ‘sqlite3_int64’ does not name a type
../src/database.cc: In static member function ‘static int Database::EIO_Open(eio_req*)’:
../src/database.cc:99: error: ‘SQLITE_OPEN_READWRITE’ was not declared in this scope
../src/database.cc:100: error: ‘SQLITE_OPEN_CREATE’ was not declared in this scope
../src/database.cc:101: error: ‘SQLITE_OPEN_FULLMUTEX’ was not declared in this scope
../src/database.cc:102: error: ‘sqlite3_open_v2’ was not declared in this scope
../src/database.cc: In static member function ‘static int Database::EIO_AfterPrepareAndStep(eio_req*)’:
../src/database.cc:274: error: ‘struct prepare_request’ has no member named ‘lastInsertId’
../src/database.cc: In static member function ‘static int Database::EIO_PrepareAndStep(eio_req*)’:
../src/database.cc:348: error: ‘struct prepare_request’ has no member named ‘lastInsertId’
../src/database.cc:353: error: ‘struct prepare_request’ has no member named ‘lastInsertId’
../src/database.cc: In static member function ‘static int Database::EIO_Prepare(eio_req*)’:
../src/database.cc:447: error: ‘struct prepare_request’ has no member named ‘lastInsertId’
../src/database.cc:452: error: ‘struct prepare_request’ has no member named ‘lastInsertId’
Waf: Leaving directory `/Users/alan/git/synapse/node-sqlite/build'
Build failed:
 -> task failed (err #1):
    {task: cxx sqlite3_bindings.cc -> sqlite3_bindings_1.o}
 -> task failed (err #1):
    {task: cxx database.cc -> database_1.o}

Please publish to npm

Please don't forget to keep your github repository and npm in sync.

Currently you have old version 0.0.2 in npm and zizzy knows which version here on github.

So annoying.

Could not find sqlite.h - any way to tell node-waf?

I couldn't compile it on a linux box, complaining about not finding the sqlite.h

After editing database.h and statement.h and putting in the paths deps/sqlite3/sqlite.h it worked. Is there a more elegant way to tell node-waf where to look for the header files?

Thanks!

synchronous bind

Does sqlite3_bind_* ever do disk I/O? If not, the bind methods should be synchronous.

Multiple Insert hack creates a segfault

try

INSERT INTO 'tablename'
      SELECT 'data1' AS 'column1', 'data2' AS 'column2'
UNION SELECT 'data3', 'data4'
UNION SELECT 'data5', 'data6'
UNION SELECT 'data7', 'data8'

Error on bind

The following code is throwing an error: http://gist.github.com/641672. I am having trouble finding the root cause in the code. The line in sqlite.js is at a bind call but the only place that error is thrown is inside database.prepare inside the cc file.

In a result row, if two fields have the same name, one of the values gets stomped.

This is more a "discussion" than an issue.

node-sqlite faithfully implements the row-as-map style expressed in the w3c spec. This is convenient for js programmers as rows are just js objects.

However if you consider a query like:

"select foo.color, bar.color from foo natural join bar"

Since each row is a map, and the key is the field name (i.e. not fully-qualified) every row in the resulting rowset will have only bar.color's value.

A clean way to handle this problem would be to have an alternative row format - that's just the values in an array in proper order, i.e. an array of values instead of the convenient js object. I'd be wiling to brush off my ancient C++ skillz and take a shot at such a thing, but I'd like some guidance / suggestion on how the api should look before I do that...the "query" method seems to be overridden to begin with, so I'm not sure where would be a good place to drop in something like a map of options ( {rowStyle:"array"} ).

Thoughts?

Not able to use callback with sqlite3_update_hook

I am using nodejs with node-sqlite (nodejs version is 0.6.6 and I an not sure how to get the version for node-sqlite that I am using.

The problem I am facing is that when I use the commented out code in (database.cc) to add a callback for update, my Node js application gets a segmentation fault. After attaching a debugger and adding a breakpoint in the UpdateHook function, I see that the segv happens on the first line of the function :

   HandleScope scope; 

Can someone tell me what I am missing?

ThanksQ

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.