How to use sqlite3 on wrangler3.20.0

I get this error when I try to use sqlite3: ✘ [ERROR] Could not resolve "mock-aws-s3" node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28: 43 │ const AWSMock = require('mock-aws-s3'); I get this for 'aws-sdk', "nock"
No description
5 Replies
Tetrax-10
Tetrax-10OP14mo ago
import sqlite3 from "sqlite3"

const db = new sqlite3.Database("data/your_database.db")

const tableName = "your_table_name"
const searchKey = "9916486"

const query = `SELECT * FROM ${tableName} WHERE row1 = ?`

db.get(query, [searchKey], (err, row) => {
if (err) {
console.error(err.message)
} else {
if (row) {
console.log("Result:", row)
} else {
console.log("Key not found.")
}
}

db.close()
})
import sqlite3 from "sqlite3"

const db = new sqlite3.Database("data/your_database.db")

const tableName = "your_table_name"
const searchKey = "9916486"

const query = `SELECT * FROM ${tableName} WHERE row1 = ?`

db.get(query, [searchKey], (err, row) => {
if (err) {
console.error(err.message)
} else {
if (row) {
console.log("Result:", row)
} else {
console.log("Key not found.")
}
}

db.close()
})
kian
kian14mo ago
Is this for a Worker? You can't run sqlite3 in a Worker
Tetrax-10
Tetrax-10OP14mo ago
Yeah workers Is there any other way to use sqlite Or any other database
Erisa
Erisa14mo ago
You can use D1 in Workers which is based off sqlite https://developers.cloudflare.com/d1/get-started/
Get started · Cloudflare D1 docs
This guide will instruct you through:
Tetrax-10
Tetrax-10OP14mo ago
Thx

Did you find this page helpful?