Expand my Community achievements bar.

Can we use sqlite3 in Adobe App Builder

Avatar

Level 3

Initialization has failed due to: Error: Could not locate the bindings file. Tried:\n → /nodejsAction/build/node_sqlite3.node\n → /nodejsAction/build/Debug/node_sqlite3.node\n → /nodejsAction/build/Release/node_sqlite3.node\n → /nodejsAction/out/Debug/node_sqlite3.node\n → /nodejsAction/Debug/node_sqlite3.node\n → /nodejsAction/out/Release/node_sqlite3.node\n → /nodejsAction/Release/node_sqlite3.node\n → /nodejsAction/build/default/node_sqlite3.node\n → /nodejsAction/compiled/18.19.0/linux/x64/node_sqlite3.node\n → /nodejsAction/addon-build/release/install-root/node_sqlite3.node\n → /nodejsAction/addon-build/debug/install-root/node_sqlite3.node\n → /nodejsAction/addon-build/default/install-root/node_sqlite3.node\n → /nodejsAction/lib/binding/node-v108-linux-x64/node_sqlite3.node\n    at bindings (/nodejsAction/CArANa4L/index.js:64381:9)\n    at 51699 (/nodejsAction/CArANa4L/index.js:141883:44)\n    at __webpack_require__ (/nodejsAction/CArANa4L/index.js:246951:42)\n    at 58203 (/nodejsAction/CArANa4L/index.js:141892:17)\n    at __webpack_require__ (/nodejsAction/CArANa4L/index.js:246951:42)\n    at /nodejsAction/CArANa4L/index.js:247035:32\n    at /nodejsAction/CArANa4L/index.js:247140:3\n    at Object.<anonymous> (/nodejsAction/CArANa4L/index.js:247143:12)\n    at Module._compile (node:internal/modules/cjs/loader:1356:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)

 

I am getting this error response when I am invoking the action   

my main function code is given below

async function main(params) {
 
const logger = Core.Logger('main', { level: params.LOG_LEVEL || 'info' })
let db;
logger.info("Sqllite testing")
try {
if (fs.existsSync(filepath)) {
db = new sqlite3.Database(filepath);
logger.info("Connected to existing SQLite database.")
} else {
db = new sqlite3.Database(filepath, (error) => {
if (error) {
return {
error: {
status:400,
body: {
message:error
}
}
}
}
logger.info("Connection with SQLite has been established");
createTable(db);
});
}
 
// Call insertRow with the db and data
// insertRow(db,params.data,logger);
 
} catch (error) {
return {
error: {
status:400,
body: {
error
}
}
}
} finally {
if (db) {
db.close(); // Close the database connection
}
}
}

function createTable(db) {
db.exec(`
CREATE TABLE IF NOT EXISTS sharks
(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
phoneno VARCHAR(50) NOT NULL
);
`);
return{
status:200,
body:{
message:"created successfully",
success:"true"
}
}
}

// function insertRow(db, data,logger) {
// const { name, email, password, phoneno } = data;

// db.run(
// `INSERT INTO sharks (name, email, password, phoneno) VALUES (?, ?, ?, ?)`,
// [name, email, password, phoneno],
// function (error) {
// if (error) {
// return {
// error: {
// status:400,
// body: {
// error
// }
// }
// }
// } else {
 
// logger.info(`Inserted a row with the ID: ${this.lastID}`)
 
// return{
// status:200,
// body:{
// message:"inserted a row",
// success:"true"
// }
// }
// }
// }
// );
// }

// main({
// "data": {
// "name": "xyz",
// "email": "xyz@gmail.com",
// "password": "xyz1234",
// "phoneno": "xxxxxxxxxxxx"
// }
// });

exports.main = main;
1 Reply

Avatar

Employee

No, you cannot use binary node modules.

There are a couple reasons why this won't work.
- The node module needs to be compiled for the target hardware, Runtime (and all serverless FaaS do not support JIT compilation)
- anything you save to your database would be lost every time your image is discarded, serverless is ephemeral

If you want to use sql you need to use DBaaS
like PlanetScale or Neon probably with an ORM like Prisma.