domingo, 16 de octubre de 2011

QSQL with SQLite

I've been trying to write a program that connects to a MySQL DB and a SQLite (I didn't found any script that converts a MySQL dump into SQLite, if you know one please let me know) In this post I just want to talk a little bit about the great QSQL

Using Qt you can write an app that connects to any of the most used DBMS like Oracle, MySQL, PostgreSQL, SQLite, and many others..The great thing about it it's that you define the database and if later you want to change to another one you can do it (that's great about the SQL standard).

I had a working example of an application that connects to a DB, it was using MySQL trough ODBC, and now with a little adjustment it uses QSQLite

    bd = QSqlDatabase::addDatabase( "QODBC" );
    bd = QSqlDatabase::addDatabase( "QSQLITE" );
 
at first I had to change the connection to QSQLITE, also the name of the database needs to
be updated 

        bd.setDatabaseName("DRIVER={MySQL ODBC 5.1 Driver};DATABASE="+nombreBD+";SERVER="+ubicacionBD);
        bd.setDatabaseName("ccomputo.sqlite");
 
With only those adjusments my application keeps working as it should..

No hay comentarios:

Publicar un comentario