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.
/*
QUrlOperator xc("http://example.com");
xc.get("testdatabase.db");
*/
QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE" );
db.setDatabaseName(xc.get("testdatabase.db"));
//idea
if( !db.open() )
{
qDebug() << db.lastError();
qFatal( "Failed to connect." );
}
sqlite is a document database meaning that its pretty much just a flat file store of your data with only the most minimal database engine on top, that is why it is like 300kb total. What you can do as a solution is to copy the db from your remote location to your location via ftp or access it by assigning a network share location to it. Be warned though that only 1 user can write to sqlite at a time.
You could use php on the server to run whatever sql commands you need and just navigate to the php page from the device.
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.
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:
The "DataSource" part has to be part of the string you build. You don't have that. You need this:
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.