Problems setting sqlite connection with nodejs and local docker

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 App.select (/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.

Mimuk did you ever sort this out?

I’ve tried setting up an SQlite and I get a similar 500 error (although the SQLITE_CANTOPEN error).

{"status":"500","code":"SQLITE_CANTOPEN","message":"SQLITE_CANTOPEN: unable to open database file","stack":"Error: SQLITE_CANTOPEN: unable to open database file"}

I’ve.

  • restarted wappler.
  • created a brand new sqlite file
  • created a new workflow using the new sqlite file.

Still same error.

As Teodor said though, can’t keep the db in the public folder. I have mine in server/db.sqlite at the root.

Not sure where else it should be?

Sorry @michaeljn I wasn’t able to get it sorted. I tried from scratch too.

Wow.

Ok, so I figured out my above can’t open error.

The DB file MUST be in the root directory. Not in a folder of the root directory.

But now despite that, despite recreating the db 5 times, adding a single table and a record. (and the table existing), I get the same error as you do.

{"status":"500","code":"SQLITE_ERROR","message":"select id, urlfromseo_metalimit 1 - SQLITE_ERROR: no such table: seo_meta","stack":"Error: selectid, urlfromseo_meta limit 1 - SQLITE_ERROR: no such table: seo_meta"}

A very odd one.

—edit.

Still looking into this. The database has been created properly and the tables do exist. Opened the file using DB Browser for SQlite.

But still getting a table not found. The query is correct. So not really sure what’s going on.

Can you please check both server connect connection and database manager connection - do they both point to the same location? Can you share screenshots of both please?

Hey Teodor,
Yep. Checked about 10 times.

I thought that as well that maybe something was corrupted. So deleted it (manually), deleted from everywhere. Then created it again using DB Manager which automatically created the DB connection in Workflows.

Has me stumped.

In DB Manager.

In Workflows/Server Connect.

You are using Docker and that has only access to some specific folders. Easiest way to get it working for now is to place your database in the app folder.

2 Likes