Problems setting sqlite connection with nodejs

I have followed each step, I can connect to my local sqlite3 file and add fields and data within the Wappler database manager.

However, when I create a simple query I get

{"status":"500","code":"SQLITE_ERROR","message":"select * from mytable - SQLITE_ERROR: no such table: mytable","stack":"Error: select * from mytable - SQLITE_ERROR: no such table: mytable"}

Are you sure you applied the changes in the database manager if the table was created there?
Are you using a local target with NodeJS exactly as explained in the docs?

Yes, I can view / edit data within Wappler and a local target NodeJS

Can you check if your database connection is properly setup in server connect as well? Test it there also.

Can you please show a few screenshots of your setup? In the database manager, in server connect etc?

Everything looks correct.
Can you try restarting (full quit and restart) Wappler and reapply the connection in the database manager? And save your server action again after that / or recreate the query.

The error message itself says that the “simple query” you wrote misspelled the name of the table myTable

select * from mytable `` would not find data from myTable

Sqlite is not case-sensitive, so mytable and myTable would both point to the same table. The error says that it can’t find the table, so it doesn’t exist in the database. Sqlite is a very simple database that stores all data in a single file, you probably pointed the direct database connection for the database manager to a different location then the database connection used in server connect.

1 Like

I started again, with a new test database, new test table, new server action running a database query (select* from test)

When opening server action in browser I got:

{"status":"500","message":"path.toSystemPath: Invalid path \"test\".","stack":"Error: path.toSystemPath: Invalid path \"test\".\n at toSystemPath (/opt/node_app/lib/core/path.js:30:19)\n at App.setDbConnection (/opt/node_app/lib/core/app.js:246:43)\n at App.getDbConnection (/opt/node_app/lib/core/app.js:268:25)\n at (/opt/node_app/lib/modules/dbconnector.js:14:25)\n at App._exec (/opt/node_app/lib/core/app.js:435:57)\n at App.exec (/opt/node_app/lib/core/app.js:375:20)\n at App.define (/opt/node_app/lib/core/app.js:365:20)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)"}

the .sqllite3 file needed to be in the public folder and then it worked as expected.

It shouldn’t be in the public folder, as this way your database is accessible for everyone.

Maybe just try recreating everything from scratch. I testet this on two different computers - windows and Mac and was not able to recreate the issue.