PyQt, Python

Connecting to MySQL using PyQt

The first thing to do in getting the database connection to your application is to install sql drivers for python. To do this you’ll need to do the following:

# sudo apt-get install python-qt4-sql

This should install the necessary libraries. To test it (which is also a demonstration of how database connections in applications are made) you’ll need to do this;

Open Python Console

# python

>>> from PyQt4.QtSql import *

>>> db = QSqlDatabase.addDatabase(“QMYSQL”)

>>> db.setDatabaseName(“information_schema”)

>>> db.setUserName(“root”)

>>> db.setPassword(“obama”)



>>> query = QSqlQuery();

>>> query.exec_(“SELECT COUNT(*) FROM TABLES;”);




>>> query.value(0).toInt();

(205, True)

You can try out a more complex query using your own database. This is not necessarily the best method just a little overview on how to do it.


Eclipse + MyLyn + Tasktop + EGit

For years now Eclipse has been my favorite IDE but recently I discovered a few tools that have made it even more appealing namely Task-oriented development with  MyLyn.

First let me talk about the problem. I was developing a project which required many plugins and in the course of development I found myself having hundreds of files. Not that I like that but development with CakePHP (MVC) made that inevitable.

Challenge: Different plugins or tasks usually involve sets of files which do not intersect. Switching between tasks therefore becomes a tedious affair. MyLyn saves the day by providing task management integrated with automated context management.

Here are a few links to give you an introduction.