Comments (9)
Found the problem. It was because the C string's null byte was being included in bind parameter. I'll land fix and make a patch release ASAP
from sqlite3.
It works! Thank you 🙏🏾
from sqlite3.
Tagged 0.2.4 with the fix
from sqlite3.
You can bind parameters to a query using the variadic arguments in queryArray
/queryObject
methods.
See: https://doc.deno.land/https://deno.land/x/[email protected]/mod.ts/~/Database#queryArray (the ...args
parameter).
For example:
db.queryArray<[string]>("select name from users where id = ?", id);
I'll add some examples to docs and test cases for it 😄
from sqlite3.
Thanks for the new documentation!
I've attempted using .queryArray
and .queryObject
multiple times without and get empty results. My database is very simple and essentially lines up to the example you just added to the documentation for binding parameters. I've triple-checked my stuff and can't see what could be wrong. I've retried the same command in the CLI and do get results.
I ran deno test
on your module and everything passes, including binding parameters. I don't know what the issue could be.
Deno version: 1.17.1 (release, x86_64-apple-darwin)
Module version: 0.2.3
macOS version: 12.1
SQLite version: 3.37.0
from sqlite3.
Could you provide a small reproduction for this case? I need something to look into to find out the issue.
from sqlite3.
I tried your the same code that for the users table and it worked fine. However, I'm still having issues with my database not showing any results. Here's the exact SQL and code I use.
import { Database } from "https://raw.githubusercontent.com/denodrivers/sqlite3/main/mod.ts";
const db = new Database("test");
db.execute("CREATE TABLE authors (author_name TEXT NOT NULL, author_username TEXT NOT NULL UNIQUE, author_bio TEXT, PRIMARY KEY (author_username));");
db.execute(`INSERT INTO authors(author_name, author_username, author_bio) VALUES ('John Doe', 'john_doe', "I'm John Doe.");`);
console.log(db.queryArray("SELECT * FROM authors"));
console.log(db.queryArray("SELECT * FROM authors WHERE author_username = ?", "john_doe"))
db.close();
Result:
> [ [ "John Doe", "john_doe", "I'm John Doe." ] ]
> []
from sqlite3.
Ah, it seems that string parameters are failing here. I will look into this right now.
from sqlite3.
Beautiful!
from sqlite3.
Related Issues (20)
- Unsafe pointer create exception HOT 4
- Bug in Reading Integers HOT 1
- `Failed to load SQLite3 Dynamic Library` – example code not working HOT 6
- SQL statement not support chinese ? HOT 1
- Running in a Web Worker HOT 6
- Different API to node-sqlite3 HOT 5
- Error: Failed to load SQLite3 Dynamic Library HOT 3
- Permission denied when trying to only allow access to a certain ffi path HOT 1
- Error: no such table: fsdir HOT 3
- Compiled binary throws zlib dependency error HOT 10
- SQLITE_ENABLE_UPDATE_DELETE_LIMIT does not work on Linux HOT 2
- Allow configuring libsqlite location HOT 5
- bump sqlite bundled version to 3.45 HOT 1
- Extensions and Callbacks prevent using this library with macOS bundled dylib HOT 6
- "TypeError: Invalid ArrayBuffer pointer, pointer is null" while reading blob column HOT 8
- Standardize SQL database interface for TS/JS HOT 1
- `new Database()` in Web Worker freezing HOT 4
- How to do WHERE col in (:array) ?
- How do I update the database? HOT 9
- Question: How to use array parameters, OR alternative? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlite3.