gSqlClient plugin for Gedit

gSqlClient is a Python plugin for Gedit that turns it into a lightweight SQL client, currently it supports MySQL, PostgreSQL, SQLite and SQLServer databases. You can examine queries resultsets on a grid, run any SQL file as a script or export resultsets as SQL, XML or CSV, taking advantage of Gedit as SQL editor.

I wrote this plugin because I missed some features of the great Oracle client Toad when working with MySQL databases, mainly the flexibility of a powerful SQL text editor where you can edit many queries on the same file and execute them separately one at a time or run the entire file as a script. With gSqlClient I can take advantage of Gedit as a powerful SQL query editor, which is an improvement over the MySQL console client (Don’t you think?), and examine the results on a more comfortable grid.

I know there are many MySQL clients out there (I always recommend MySQL Query Browser) and they are great so, why do I need one more client?. Well, when I come interested in Python language this was the first thing I thought for learning the language, something easy, something useful, what else?

The project is licensed under the terms of the GNU General Public License version 3. Until 2011-08-22 it was hosted on GoogleCode, and since then, the development of the 1.0 branches are hosted in GitHub. You can browse the sources and download the last version from or

And give some feedback please, report bugs or simply let me know what do you think about gSqlClient, enjoy!.



You will need to install only the drivers you want to use. It’s possible that your Linux distribution has precompiled packages available.

Driver Since Version URL Tested
MySQL (MySQLdb) 0.1 Linux / MySQL 5
SQLite (Pysqlite) 0.4 Linux / SQLite 3
PostgreSQL (Psycopg) 0.5 Linux / PostgreSQL 8.4
SQLServer (Pymssql) 0.5 -

Usage and features

Open Gedit, create a new document, and follow the next instructions:

Connect/disconnect Gedit to a server

Access to that operations by pressing Ctrl+Shift+C, a dialog appears where you have to fill the form with your specific server information. The server host can be written as HOST_NAME[:PORT] or as a path to a socket file. The schema field is optional.

When you want to disconnect from the server press Ctrl+Shift+C again, if the connection was successfully a new button, Disconnect, will be available.

Remember that you can have one diferent open connection on each Gedit tab so you can query diferent databases from the same instance of Gedit.

When you close Gedit, the plugin will attempt to disconnect all the opened connections for you.

Executing queries

Write some queries and be sure to separate them by empty lines, put the cursor over one of the queries and press Ctrl+Return, you should see a panel with the resultset (Or maybe with a SQL error…). The query separator is an empty line so you don’t need a semicolon after the query, this way allows you to have many queries on the same document and execute them separately.

If you want to execute only part of a query you can select the part you are interested on and press Ctrl+Return, the plugin will only execute the selection.

For example, you are going to run this query: SELECT * FROM Table1 WHERE field_id IN (SELECT field_id FROM Table2) but first you want to examine the returned data from the subquery, ok, don’t write the subquery again, only select it and press Ctrl+Return, easy?.

Not only can execute DML and DDL queries, you can run anything you run habitually from the console client, server administration, user administration or whatever.

Running files as scripts

This is interesting when you need to run many queries. By pressing Ctrl+Shift+R gSqlClient will execute all the queries on the document one after one (remember to separate them by empty lines) and show the results of each one in the bottom panel.

Before the execution, a dialog appears where you can choose three diferent options for the error control:

Copying and exporting resultset data (since version 0.2)

There is a contextual menu with options for copy grid values and export resultsets as SQL, XML or CSV formats, simply right click on the resultset grid and select the option you want.


I don’t have in mind to add much more features, but I have two things pending:


gSqlClient-0.5 (2011-05-24)

gSqlClient-0.4 (2011-01-18)

gSqlClient-0.3 (2010-12-21)

gSqlClient-0.2 (2009-08-17)

gSqlClient-0.1 (2009-08-11)

gSqlClient-0.1-beta (2009-08-04)