Using Sqlite3 with Anvil

I have written a payroll software. Previously it was planned to be a desktop software. But now I want to use Anvil stack (rather than going through horrific QT framework).

I am running anvil server locally trying to connect to sqlite3 database from anvil server side module.

In my server side module I have a database connection string like this

db = dataset.connect('sqlite:///database//payroll.db',row_type=stuf)

The payroll.db file is located in database folder within server_code. But I am keep getting Sqlite Operational Error, Unable to open database file.

Can anyone tell me whats wrong. I think its something to do with path (I am using dataset library for connection to database which is a high level wrapper around SQLCHEMY.)

The above code connect perfectly to database outside anvil.

Hi @ehsensiraj, the css and javascript files should be in _/theme/ folder. So I guess it might be the case with your file as well

The sqlachemy connection string uses a relative path. You can either change this to be an absolute path, or find out what the current working directory within the anvil server process is (unlikely to be server_code).

Alternatively, you could use the postgresql instance that’s an integral part of the app server. You’re not tied to using the data tables service, you can do whatever you want within that dbms.

Thanks everyone, I have tried everything from absolute path to pretty much everything I can think of. Nothing worked.

@owen.campbell Yup you are right, using postgresql should be the database choice in my case.