Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
81c64d08
Commit
81c64d08
authored
Feb 14, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't create a new object but use the binding's objects directly instead
parent
fb3cf5f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
38 deletions
+22
-38
sqlite3.js
lib/sqlite3.js
+22
-38
No files found.
lib/sqlite3.js
View file @
81c64d08
/*
// Copyright (c) 2009, Eric Fredricksen <e@fredricksen.net>
Copyright (c) 2009, Eric Fredricksen <e@fredricksen.net>
// Copyright (c) 2010, Orlando Vazquez <ovazquez@gmail.com>
Copyright (c) 2010, Orlando Vazquez <ovazquez@gmail.com>
//
// Permission to use, copy, modify, and/or distribute this software for any
Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
var
sqlite3
=
module
.
exports
=
exports
=
require
(
'./sqlite3_bindings'
);
var
sys
=
require
(
"sys"
);
var
sys
=
require
(
"sys"
);
var
sqlite
=
require
(
"./sqlite3_bindings"
);
var
Database
=
exports
.
Database
=
function
()
{
var
self
=
this
;
var
db
=
new
sqlite
.
Database
();
db
.
__proto__
=
Database
.
prototype
;
return
db
;
};
Database
.
prototype
=
{
__proto__
:
sqlite
.
Database
.
prototype
,
constructor
:
Database
,
};
Database
.
prototype
.
query
=
function
(
sql
,
bindings
,
rowCallback
)
{
sqlite3
.
Database
.
prototype
.
query
=
function
(
sql
,
bindings
,
rowCallback
)
{
var
self
=
this
;
var
self
=
this
;
if
(
typeof
(
bindings
)
==
"function"
)
{
if
(
typeof
(
bindings
)
==
"function"
)
{
...
@@ -84,7 +68,7 @@ function _doStep(db, statement, rowCallback) {
...
@@ -84,7 +68,7 @@ function _doStep(db, statement, rowCallback) {
// Execute a single SQL query with the given optional parameters. Calls
// Execute a single SQL query with the given optional parameters. Calls
// `callback` with all rows or an error on query completion.
// `callback` with all rows or an error on query completion.
Database
.
prototype
.
execute
=
function
(
sql
/* , bindings, callback */
)
{
sqlite3
.
Database
.
prototype
.
execute
=
function
(
sql
/* , bindings, callback */
)
{
var
self
=
this
;
var
self
=
this
;
var
bindings
,
callback
;
var
bindings
,
callback
;
var
n
=
arguments
.
length
;
var
n
=
arguments
.
length
;
...
@@ -136,7 +120,7 @@ Database.prototype.execute = function (sql /* , bindings, callback */) {
...
@@ -136,7 +120,7 @@ Database.prototype.execute = function (sql /* , bindings, callback */) {
// Execute SQL statements separated by semi-colons.
// Execute SQL statements separated by semi-colons.
// SQL must contain no placeholders. Results are discarded.
// SQL must contain no placeholders. Results are discarded.
Database
.
prototype
.
executeScript
=
function
(
script
,
callback
)
{
sqlite3
.
Database
.
prototype
.
executeScript
=
function
(
script
,
callback
)
{
var
self
=
this
;
var
self
=
this
;
(
function
stepOverSQL
(
sql
)
{
(
function
stepOverSQL
(
sql
)
{
...
@@ -170,7 +154,7 @@ Database.prototype.executeScript = function (script, callback) {
...
@@ -170,7 +154,7 @@ Database.prototype.executeScript = function (script, callback) {
})(
script
);
})(
script
);
}
}
Database
.
prototype
.
insertMany
=
function
(
table
,
columns
,
rows
,
callback
)
{
sqlite3
.
Database
.
prototype
.
insertMany
=
function
(
table
,
columns
,
rows
,
callback
)
{
var
columnsFragment
=
columns
.
join
(
","
);
var
columnsFragment
=
columns
.
join
(
","
);
var
placeholdersFragment
=
[];
var
placeholdersFragment
=
[];
var
i
=
columns
.
length
;
var
i
=
columns
.
length
;
...
@@ -226,7 +210,7 @@ Database.prototype.insertMany = function (table, columns, rows, callback) {
...
@@ -226,7 +210,7 @@ Database.prototype.insertMany = function (table, columns, rows, callback) {
}
}
exports
.
fromErrorCode
=
function
(
code
)
{
sqlite3
.
fromErrorCode
=
function
(
code
)
{
switch
(
code
)
{
switch
(
code
)
{
case
0
:
return
"SQLITE_OK"
;
case
0
:
return
"SQLITE_OK"
;
case
1
:
return
"SQLITE_ERROR"
;
case
1
:
return
"SQLITE_ERROR"
;
...
@@ -258,7 +242,7 @@ exports.fromErrorCode = function(code) {
...
@@ -258,7 +242,7 @@ exports.fromErrorCode = function(code) {
}
}
};
};
exports
.
sanitizeError
=
function
(
err
,
data
)
{
sqlite3
.
sanitizeError
=
function
(
err
,
data
)
{
err
.
message
=
exports
.
fromErrorCode
(
err
.
errno
)
+
', '
+
err
.
message
+
err
.
message
=
exports
.
fromErrorCode
(
err
.
errno
)
+
', '
+
err
.
message
+
' in query "'
+
err
.
query
+
' in query "'
+
err
.
query
+
'" with values '
+
JSON
.
stringify
(
data
,
false
,
4
);
'" with values '
+
JSON
.
stringify
(
data
,
false
,
4
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment