Results 1 to 5 of 5

Thread: MySQL, locking tables

  1. #1
    Join Date
    Apr 2006
    Location
    Narvik, NORWAY
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Windows

    Wink MySQL, locking tables

    Does any of Qt's QSql.....-classes take care of locking/unlocking tables in MySQL database?
    I can't find anything about that in Qt Assistent.

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

    Default Re: MySQL, locking tables

    Qt sql classes use client libraries to achieve their tasks. If you want to issue a table lock command, you have to specifically ask for it using a "LOCK TABLE" query. Qt won't lock tables on its own. It doesn't need locking to perform its tasks. I don't know if this answers your question though

  3. #3
    Join Date
    Apr 2006
    Location
    Narvik, NORWAY
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Windows

    Red face Re: MySQL, locking tables

    What is client libraries in this context?

    What if you have a system with many connections to the same database? Don't you have to lock tables to make sure your lookups are consistent every time?

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

    Default Re: MySQL, locking tables

    Quote Originally Posted by gunhelstr
    What is client libraries in this context?
    SQL database management systems (like MySQL) provide libraries, which allow other programs to query databases, etc. (the library is called libmysqlclient when it comes to MySQL). Qt uses those libraries to make "lowlevel" (database) calls to provide "high level" (QSQL driver) functionality.

    What if you have a system with many connections to the same database? Don't you have to lock tables to make sure your lookups are consistent every time?
    It is the database management system's responsibility to provide query consistency. Qt doesn't handle that. It just uses the client library to issue queries to the database.

    BTW. To assure the consistency of a query the DBMS often lock single rows, but they avoid locking whole tables if they can. If you want to lock the whole table, you have to make a query for it yourself.
    Last edited by wysota; 4th May 2006 at 13:39.

  5. #5
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MySQL, locking tables

    Do you need to explicitly lock a row for some reason, or do you just want locking as part of a "transactional" process?

    If you call .transaction() on your QSqlDatabase you can insert new rows, then they won't appear until you .commit() the transaction after all your queries are performed.

    Transactions usually work on select statements as well locking rows that you return with select statements, although I don't know if MySql in fact does that. Transactions are pretty new to MySql and I haven't actually tried 'select' based transaction to know if it works.

    This of course may not be what you're after, but I hope it helps


    Steve

Similar Threads

  1. mysql configuration with qt
    By bala in forum Installation and Deployment
    Replies: 3
    Last Post: 6th November 2007, 12:02
  2. MySQL starting problem
    By shamik in forum General Discussion
    Replies: 5
    Last Post: 25th April 2007, 08:20
  3. Qt 4.1.4 & Mysql 5 on Linux x64
    By bothapn in forum Installation and Deployment
    Replies: 7
    Last Post: 4th August 2006, 14:23
  4. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 21:22

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.