Featured post
sql - Polling MySQL database through Qt / QSqlTableModel (C++) -
i'm using qt connect mysql database (through qsqltablemodel / qsqldatabase / etc) although question more general.
what's best way "live updating database table view"? 1 option poll entire table (repeatedly calling select() method in qsqltablemodel). seems inefficient though (is entire table passed mysql qt each time?)
another option have table, acts log table (keeps track of updates / changes) , can poll log table (checking new entries..which seems more efficient?). however, lose lot of qsql built in functionality).
or should have counter variable poll, , if increases, know refresh entire table?
all these approaches seem bit messy.. recommend? thanks.
this mysql question have answer! :)
what want in fact poll database every x seconds. however, make efficient if make mysql "trigger" if row inserted, updated, and/or deleted create indicator.
i think should create trigger insert modified row second table. poll qt program should these actions:
- lock second "modifications" table
- read entire contents of second "modifications" table
- delete contents of second "modifications" table
- unlock second "modifications" table
if dont lock table accidentally delete new row inserted between reading , deleting. however, if want/need avoid locking, read everything, delete rows retrieved based on unique id generated each row insertion "modifications" table.
the faq , documentation mysql triggers here: http://dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html
documentation locking/unlocking tables here: http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
- Get link
- X
- Other Apps
Comments
Post a Comment