I am wondering how i can access an sqlite database that is sitting a remote server.I have read threads discouraging it but i need to do it if its possible.
SQLite is file-based only. There is no way to talk to it over TCP/IP.
Like an Access database file, you have to have the database file in a network shared folder. The path is usually going to be a UNC path, like "\server\sharename\folderpath\databasefile".
The problem is the connection string you built isn't a connection string. It's a partial string. You have this:
DataSource = @"\\\\" + txtipaddress.Text + @"\qscanDBAttacheds\test.s3db;Version=3;New=False;Compress=True;"
The "DataSource" part has to be part of the string you build. You don't have that. You need this:
string connString = @"Data Source=\\" + txtipaddress.Text + @"\qscanDBAttacheds\test.s3db;Version=3;New=False;Compress=True;"
While sqlite itself does not provide any network endpoints you can use a web gui such as sqlite-web.
Assuming you have python installed you can install it with
pip install sqlite-web
Once installed, start the web interface with:
sqlite_web my_database.db
By default it runs on http://127.0.0.1:8080/ ie is only accesible from the localhost.
To make it visible on your LAN/WAN start it with:
sqlite_web --host 0.0.0.0 my_database.db
While running with --host 0.0.0.0
is fine on your own home network, it's a really bad idea to do it on a public host (even though the app allows setting a password). For remote access on a public host it would be safer running it on 127.0.0.1
and then forward the port over ssh.
Disclaimer: I am not affiliated with the author of the app. Just had the same need as the op and found the app on github.
You could use php on the server to run whatever sql commands you need and just navigate to the php page from the device.
SQLite isn't a network database, so it doesn't have any network connection ability built into it.
You would need to either:
A web application is essentially a web service. If you happen to be running a web application on top of this DB, just expose certain levels of DB access to admins-only.
It's not recommended you do this because multiple threads/clients/etc. accessing a SQLite DB simultaneously may lead to concurrency problems very quickly.
Navicat can connect via SSH to a remote sqlite database.
For smaller project im using phpliteadmin
You cannot directly access an sqlite database remotely like that. If you need to share it, you will have to develop a web service and talk to the web service rather than the database from your Qt Application.
There are some tools which act as a web service for stuff like that, e.g. this site has some links.