Results 1 to 20 of 28

Thread: Database Drivers Related to Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Hi Leslok,

    Thanks for the Advice.........I came to know very before through that link only that we can access different databases using Qt.....but i just wanted to know how exactly can i create a pluginn for Mysql i have gone through the links and a bit confused with it.......Wanna know what line or statement can i add in the .pro file ........Thats whai i am looking for i found in the link that mysql is stored in /usr/local where in my system its stored in /usr/share so im a bit confused with it....Can anyone give me a better solution......Any Solution would be appreciable.....Thanks in advance......


    Regards,

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Database Drivers Related to Qt

    Quote Originally Posted by StarRocks View Post
    Thanks for the review....I havent asked anything other than QT related issues i was asking can i use db which is not Sqlite as i have google searched and found that we can use Mysql,Psql i guess thats completely related to QT if im not wrong.......I just want to know how to add plugins,drivers related to Mysql,Psql in QT........that was my Question Wysota.......Thanks in Advance ....Any solution would be appreciable..........
    I think you are referring to my signature.

    Quote Originally Posted by StarRocks View Post
    Thanks for the Advice.........I came to know very before through that link only that we can access different databases using Qt.....but i just wanted to know how exactly can i create a pluginn for Mysql i have gone through the links and a bit confused with it.......Wanna know what line or statement can i add in the .pro file ........Thats whai i am looking for i found in the link that mysql is stored in /usr/local where in my system its stored in /usr/share so im a bit confused with it....Can anyone give me a better solution......Any Solution would be appreciable.....Thanks in advance......
    You don't have to create any plugins. A plugin for MySQL is already available. As long as you have it installed, using it is just a matter of calling QSqlDatabase::addDatabase().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Database Drivers Related to Qt

    All the plugin are already available. For using it just write QT += sql in .pro file.

    See the ewxample:-
    Qt Code:
    1. #include <QtGui>
    2. #include <QtSql>
    3. int main(int argc,char* argv[])
    4. {
    5. QApplication app(argc,argv);
    6. QTableWidget* table = new QTableWidget();
    7. table->setWindowTitle("Connect to Mysql Database Example");
    8.  
    9. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    10. db.setHostName("192.168.11.3");
    11. db.setDatabaseName("menudb");
    12. db.setUserName("root");
    13. db.setPassword("test");
    14. if (!db.open())
    15. {
    16. QMessageBox::critical(0, QObject::tr("Database Error"),
    17. db.lastError().text());
    18. }
    19.  
    20. QSqlQuery query("SELECT * FROM test");
    21.  
    22. table->setColumnCount(query.record().count());
    23. table->setRowCount(query.size());
    24.  
    25. int index=0;
    26. while (query.next())
    27. {
    28. table->setItem(index,0,new QTableWidgetItem(query.value(0).toString()));
    29. table->setItem(index,1,new QTableWidgetItem(query.value(1).toString()));
    30. index++;
    31. }
    32.  
    33. table->show();
    34. return app.exec();
    35. }
    To copy to clipboard, switch view to plain text mode 

    This is how you connect the QT with MySql.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  4. #4
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Hi Sonulohani,

    Thanks for the reply............I have worked on the example that you send me and its working fine.....
    Regards,


    Added after 51 minutes:


    Dear Sonulohani,


    I have one more doubt can i connect to SqlServer and QPSQL from QT because when i try to connect to the given databases it not allowing me to retrieve data rather showing me an error that "Drivers not supported" .......So please let me know is it possible to connect if so how can i create pluginns for it..............Thanks in Advance...........Any solution would be appreciable......


    Regards,
    Last edited by StarRocks; 8th October 2012 at 11:27.

  5. #5
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Database Drivers Related to Qt

    Check the installed SQL Database drivers from this:-

    Qt Code:
    1. qDebug()<<db.drivers();
    To copy to clipboard, switch view to plain text mode 

    It will display a list of sql drivers installed in your system.

    If you don't have that driver then you have to build it.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  6. #6
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear sonulohani,


    Thanks for the reply..........I already know that i have only Mqsql and Sqlite in my System...I would like to know how to build a library file because that solves problems of most of the database connectivity if im not wrong......Thnaks in Advance....Any Solution would be appreciable..........


    Regards,

  7. #7
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Database Drivers Related to Qt

    Hey,hit on the thanks button.

    Here is the tutorial for how to build the QPSQL plugin:-

    http://www.qtcentre.org/wiki/index.p...ws_using_MinGW
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  8. The following user says thank you to sonulohani for this useful post:

    StarRocks (8th October 2012)

  9. #8
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear sonulohani,


    Thanks for the reply..........Im not using Windows im using Linux OS(Ubuntu).........So can you send me the steps related to building of drivers it would be good if you send me for those........Thanks in advance.........Any solution would be appreciable.........


    Regards,

  10. #9
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Database Drivers Related to Qt

    QPSQL for PostgreSQL (Version 7.3 and Above)

    General Information about the QPSQL driver

    The QPSQL driver supports version 7.3 and higher of the PostgreSQL server. We recommend that you use a client library from version 7.3.15, 7.4.13, 8.0.8, 8.1.4 or more recent as these versions contain security fixes, and as the QPSQL driver might not build with older versions of the client library depending on your platform.
    For more information about PostgreSQL visit http://www.postgresql.org.

    QPSQL Unicode Support
    The QPSQL driver automatically detects whether the PostgreSQL database you are connecting to supports Unicode or not. Unicode is automatically used if the server supports it. Note that the driver only supports the UTF-8 encoding. If your database uses any other encoding, the server must be compiled with Unicode conversion support.
    Unicode support was introduced in PostgreSQL version 7.1 and it will only work if both the server and the client library have been compiled with multibyte support. More information about how to set up a multibyte enabled PostgreSQL server can be found in the PostgreSQL Administrator Guide, Chapter 5.

    QPSQL BLOB Support
    Binary Large Objects are supported through the BYTEA field type in PostgreSQL server versions >= 7.1.
    How to Build the QPSQL Plugin on Unix and Mac OS X
    You need the PostgreSQL client library and headers installed.
    To make qmake find the PostgreSQL header files and shared libraries, run qmake the following way (assuming that the PostgreSQL client is installed in /usr):
    Qt Code:
    1. cd $QTDIR/src/plugins/sqldrivers/psql
    2. qmake "INCLUDEPATH+=/usr/include/pgsql" "LIBS+=-L/usr/lib -lpq" psql.pro
    3. make
    To copy to clipboard, switch view to plain text mode 

    After installing Qt, as described in the Installing Qt on X11 Platforms document, you also need to install the plugin in the standard location:
    Qt Code:
    1. cd $QTDIR/src/plugins/sqldrivers/psql
    2. make install
    To copy to clipboard, switch view to plain text mode 
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Database Drivers Related to Qt

    Quote Originally Posted by StarRocks View Post
    Thanks for the reply..........Im not using Windows im using Linux OS(Ubuntu).........So can you send me the steps related to building of drivers it would be good if you send me for those........Thanks in advance.........Any solution would be appreciable.........
    sudo apt-get install libqt4-sql-psql postgresql-client
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear wysota,

    Thanks for the reply..........I have already installed Postgresql in my system i query is how would i use it in Ubuntu i am very confused when to add the lines that you were asking me to do...........Let me know the suitable and understandable steps to build a .so file for the related database Postgresql and Sql Server.Thanks in advance........Any solution would be appreciable.......


    Regards,

  13. #12
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Database Drivers Related to Qt

    sudo apt-get install libqt4-sql-psql postgresql-client
    This is the psql library for qt. There is no need to build the library. Just install it. It will automatically create the .so lib.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  14. #13
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear sonulohani,

    Thanks for your valuable favour..........But say me where can i find the above mentioned .so file ............Thanks in advance......Any solution would be appreciable is it the same for Sql Server..........

    Regards,


    Added after 4 minutes:


    Dear sonulohani,


    I have done with Postgresql and its working fine now i want to try with ODBC im very confused because ODBC means oracle related db but found in good search that it supports Sql server........So jus say me how to build a library for that..........Any solution would be appreciable.........Thanks n Advance................


    Regards,
    Last edited by StarRocks; 8th October 2012 at 13:40.

  15. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Database Drivers Related to Qt

    Quote Originally Posted by StarRocks View Post
    how would i use it in Ubuntu i am very confused when to add the lines that you were asking me to do
    http://www.lmgtfy.com?q=apt-get+ubuntu
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #15
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear Wysota,

    I have done with Postgresql..........But having a problem with ODBC not knowing how to do it........Can you just help me out the way that you done for rest of the databases...........Thanks in advance......Any solution would be appreciable.......

    Regards,

  17. #16
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear Wysota,

    Thanks for the reply........Can you send me the same steps for ODBC like the way you sent me for PSQL ......I mean the commands that you sent me right similarly the same way can you give me in the form of step wise......Thanks in advance..........Any solution would be appreciable.....

    Regards,

  18. #17
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    5

    Default Re: Database Drivers Related to Qt

    Dear Wysota,

    Thanks for the reply......As you gave me a link to find out right but im not knowing what this link will helpout me..I need to build drivers right for ODBC ....Can you give me in brief how do i run in Terminal of Ubuntu....That would be helpful......Thanks in advance....Any Solution would be appreciable....
    http://www.lmgtfy.com?q=apt-get+ubuntu

    Regards,

Similar Threads

  1. Database drivers missing
    By EvIL_GuY in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2012, 23:00
  2. Replies: 1
    Last Post: 9th January 2012, 00:23
  3. how to install DataBase Drivers
    By un9tsandeep in forum Qt Programming
    Replies: 2
    Last Post: 4th October 2011, 12:44
  4. LGPL and distributing QT database drivers
    By BitRogue in forum General Discussion
    Replies: 4
    Last Post: 7th July 2011, 09:32
  5. database drivers - installation
    By banita in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2010, 19:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.