Results 1 to 6 of 6

Thread: QSQLDatabase

  1. #1
    Join Date
    Apr 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Question QSQLDatabase

    hi,

    if I create a QSqlDatabase, the .open() method call is extremly slow.
    Does anyone know whats wrong?

    best

    ps.: I'm connecting on a local database

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

    Default Re: QSQLDatabase

    Please provide more details.
    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
    Apr 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSQLDatabase

    I'm adding a database using the driver QPSQL7 :

    Qt Code:
    1. m_db = QSqlDatabase();
    2. ...
    3. m_db = QSqlDatabase::addDatabase(strType.c_str(), DB_NAME);
    4. m_db.setHostName(strHostName.c_str());
    5. m_db.setDatabaseName(strDatabaseName.c_str());
    6. m_db.setUserName(strUserName.c_str());
    7. m_db.setPassword(strPassword.c_str());
    8. m_db.setPort(iPort);
    9. ...
    To copy to clipboard, switch view to plain text mode 

    while calling:
    Qt Code:
    1. m_db.open();
    To copy to clipboard, switch view to plain text mode 
    my app blocks for about two seconds

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

    Default Re: QSQLDatabase

    Does it also block for two seconds if you use psql console? Maybe your database is clogged and needs some vacuuming? How did you calculate those two seconds, by the way? Like that?
    Qt Code:
    1. t.start();
    2. m_db.open();
    3. qDebug() << t.elapsed();
    To copy to clipboard, switch view to plain text mode 
    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.


  5. #5
    Join Date
    Apr 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSQLDatabase

    Yes I did that...

    I tried to vacuum the database (VACUUM tablename; ) before calling
    Qt Code:
    1. m_db.open()
    To copy to clipboard, switch view to plain text mode 

    But that caused a timedelay of 2,2 seconds... I have no clue whats wrong...

    best,
    Hoshy

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSQLDatabase

    Again, how do you calculate the delay?
    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.


Similar Threads

  1. Sqlite & QSqlDatabase problem
    By rsimone in forum Newbie
    Replies: 5
    Last Post: 29th July 2009, 21:52
  2. QSqlDatabase connectivity issues
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 16th July 2008, 12:58
  3. QSqlDatabase Mysql timeout versus PortScanner
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2008, 00:08
  4. GCC can't find QSqlDatabase!!
    By brevleq in forum Qt Programming
    Replies: 5
    Last Post: 29th October 2007, 07:05
  5. Passing around a QSqlDatabase
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 8th September 2007, 08:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.