SQLite User Forum

Sqlite for Web App
Login

Sqlite for Web App

(1) By fkayhan (19662004) on 2022-04-24 08:40:59 [link] [source]

Good days; I have a web app and I like to use Sqlite. However, I could not figure out how to set the path for DataBase file. In my desktop application I am able to use Sqlite very easly because databaese file is in my local PC.

In my webapp, when I publish it into internet. Database path is still trying to look into my local folder and gives error.

How must be the path setting for database file so that web app in internet browser will search the database in my cloud server.

(2) By Simon Slavin (slavin) on 2022-04-24 19:54:17 in reply to 1 [link] [source]

To specify the path for your SQLite database do the same thing as if you were specifying the path for a text file. If you can open a text file in that folder, you can open a SQLite database in the same folder.

There are many ways to make a web app consult SQLite. We do not know which one you are using. And how to use a web app is not the subject of this forum anyway. You should look for a forum which can help with using your web app.

(3) By Ryan Smith (cuz) on 2022-04-24 21:41:15 in reply to 1 [link] [source]

I feel like this post must hold some record for least info-per-words-used.

What do you mean by web app? Perhaps start by saying which language/platform the app is developed in.

If the web-app in some way serves http requests, it gets the files (and SQLite DBs) on the web-app server computer which should be local to the app, much the same way a desktop app gets it from its local machine.

This means also that once you publish your web app, the server needs to get a copy of the SQLite DB file so that it can access it locally (on itself).

Where exactly on the web server you must place the file depends. If you are using PHP+Apache, say, then the DB file can typically be in the PHP local folder, or anywhere else on the machine as long as Apache/PHP service (and the user it operates under) is allowed to access it there, and the correct path is set in your web-app code/config.

Simon is right, this is probably more of a web-app question than an SQLite one, and this answer is probably less useful than a chocolate teapot, but if you describe the build environment and show your code, perhaps someone here could have helped you, but as it stands now, we can only make bad guesses.

(4) By Donal Fellows (dkfellows) on 2022-04-25 15:15:35 in reply to 1 [source]

There are two ways that work:

  1. Create a service somewhere that accesses the database file. The database file must be local to that service instance. (The filename you use is "local" from the perspective of the system running the service you write; it has no contact with your developer machine.)
  2. Download the database file (it's just an ordinary file!) and work with it locally. You won't be able to propagate changes you make easily this way, but not all applications need that.

I actually use method #1 quite a bit. As long as your transactions are short and your write workload isn't too much, it's pretty workable. There are lots of different ways to achieve it; more than I'm willing to try enumerating.

What does not work is directly accessing a database file remotely. The fundamental problem is that file locking in networked filesystems is always dodgy at best. It's a basic technology problem (networks are unreliable because of the sheer number of weird things that can go wrong) and one that isn't going away.