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.
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.
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![]()
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?
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.Originally Posted by gunhelstr
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.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?
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 12:39.
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
Bookmarks