The driver gets built with the Qt installation (or not). Not sure why it isn't there if you have a valid QtSql module. Maybe it was excluded. Or maybe mysql was not installed when your Qt build was built so the plugin is missing? This page has more info: http://qt-project.org/doc/qt-4.8/sql-driver.html#building-the-drivers-using-configure
That aside, here are two other options. If you want to stick with the QtSql module and just make your own support for your mysql connector, you could subclass your own QSqlDriver and maybe QSqlResult http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-write-your-own-database-driver Or you can skip QtSql completely. Just use a QTableWidget, or a QTableView/QStandardItemModel. When you refresh you would do your select with your python mysql client, then clear and add items to the table. On Nov 7, 2012, at 11:58 PM, PBLN RAO <[email protected]> wrote: > Justin, > > I have seen ur post in stackoverflow. in the example its Postgresql Database > but i am using MySQL as my database. > > I changed the line as below > > db = QtSql.QSqlDatabase.addDatabase("QMYSQL", "MyDatabaseConnectionName") > > and gotthe below error message. > > QSqlDatabase: QMYSQL driver not loaded > QSqlDatabase: available drivers: QSQLITE > > And in the internet i could not find MySQL driver for PyQt. > > I have MySQL Connector for Python and its working fine for connecting to > database with Python. > > Do you have and idea If any one have compiled MySQL Connector/Driver for > PyQt4. > > On Thursday, November 1, 2012 10:53:59 PM UTC+5:30, Justin Israel wrote: >> >> I answered a question back in July on Stackoverflow about how to use a QtSql >> model to populate a QTableView: >> http://stackoverflow.com/a/11624784/496445 >> >> You create the database and model, then you set a query on it and select. >> Any view connected to the model will use that data from the results. You can >> also tell it which column of results to view, if you are using a list/column >> view. >> >> >> >> On Thu, Nov 1, 2012 at 12:28 AM, PBLN RAO <[email protected]> wrote: >>> Hi, >>> >>> I have an application with database. >>> >>> I want to display the data retrieved from database in table view with >>> column filter option. >>> >>> I know how to do it in .NET. now i need to know how can get it in python. >>> >>> My Database is MySQL. >>> >>> I have a module to query the database which takes database_name and SQL >>> command to be executed on that table, and will return the result as >>> dictionary. >>> This dictionary need to be linked to TableView/Column View which every >>> suits the best in my scenario. >>> -- >>> view archives: http://groups.google.com/group/python_inside_maya >>> change your subscription settings: >>> http://groups.google.com/group/python_inside_maya/subscribe > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
