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." );
}
you can consider switching to PostgreSQL instead of SQLite, the database manipulation is very similar. The little differences in handling primary keys etc you can google. For example in the INSERT statement you'd pass a NULL in SQLite, as a primary key and in Postgre you'd pass it as DEFAULT (given you want the database to create the key for you).
In Python3 for example, the code difference I know of is that PostgreSQL allows remote connection and that avoiding SQL injection syntax is slightly different, as SQLite3 way would be with
?
and PostgreSQL9.5 would be with%s
Switching to Postgre would provide you a remote connection possibility and it is a definite step up from using a local database (which is only designed for small to medium bandwidth applications).