Gerald is a general purpose toolkit written in Python for cataloguing, managing and deploying database schemas. Its major current use is to identify the differences between various versions of a schema. A schema is a single logical grouping of database objects usually made up of tables, views and stored code objects (functions and procedures).
You can use Gerald to determine the differences between your development and test environments, or to integrate changes from a number of different developers into your integration database.
Gerald is designed to be used in an Agile environment, but is useful regardless of your development methodology.
Gerald is designed from the ground up to support as many popular relational database systems as possible. Currently it will document and compare schemas from databases implemented in MySQL, Oracle and PostgreSQL. Other databases will be supported in future releases.
I wrote this module because I was looking for a cheap, alright - free, tool with similar functionality to ERWin and other commercially available database modelling and management tools. I didn't find anything so I ended up keeping my data model in an Excel spreadsheet and wrote some scripts to generate my Data Definition Language (DDL) into files. The one thing that they didn't do, though, was enable me to easily discover the differences between my model and what was deployed in the various databases we were using. So I started writing the code that became this module.
Of course, by the time it was usable the project was long finished. I carried on though, because I'll need the same functionality on my next project and undoubtedly the one after that as well. As it's fun to share, I'm putting this code up on the internet for anyone to use as they see fit. It is licensed under the BSD License (see LICENSE.txt in the distribution).
Gerald can currently extract and compare schemas, and in future I'm hoping that it will expand to store them as well, taking over from my Excel spreadsheet. Given infinite time, I'd hope to expand its capabilities to the level of tools like ERwin and Oracle Designer.
Everything you need to get and run Gerald is at these links;
svn checkout http://halfcooked.svn.sourceforge.net/svnroot/halfcooked/tags/release-0.2.3/gerald/ gerald/
To install Gerald you need to download the code (from the download page) and then at the command line type;
python setup.py install
Gerald is written in Python and requires a DB-API module to interact with your database. In the current release we support Oracle, MySQL and PostgreSQL databases. Because the code is designed to be modular and extensible adding support for different databases is quite simple. All it requires is new sub-classes of the generic classes in schema.py. They will need to be adapted for the data dictionary provided by the database.
To compare the same schema in two Oracle databases start an interactive session and type;
>>> import gerald
>>> first_schema = gerald.OracleSchema('first_schema', 'oracle:/[username]:[password]@[tns connection]')
>>> second_schema = gerald.OracleSchema('second_schema', 'oracle:/[2nd username]:[2nd password]@[2nd tns connection]')
>>> print first_schema.compare(second_schema)
You can display a reader friendly version of your schema like this;
>>> import gerald
>>> my_schema = gerald.MySQLSchema('schema_name', 'mysql:/[username]:[password]@[hostname]/[catalog name]')
>>> print my_schema.dump()
You can display an XML representation of your schema like this;
>>> import gerald
>>> my_schema = gerald.OracleSchema('schema_name', 'oracle:/[username]:[password]@[tns entry]')
>>> print my_schema.to_xml()
For more information on the available objects and methods, look at the module API documentation.
This is release 0.2.3 of Gerald. It's still alpha code, but it is in use on and does provide some value. Having said that, I'm fairly happy with the current functionality so I will only change it if I absolutely have to, and then usually to extend the features available. The major changes in this release are the addition of even more unit tests and the renaming of most of the modules, classes and methods to conform to the standard Python naming conventions (detailed in PEP 8)
The core function is fairly solid and will support a number of enhancements. I'm specifically thinking about, but in no particular order;
If anyone has suggestions I'm happy to hear your thoughts. Send an email to andy47@halfcooked.com
| Author: | andy47@halfcooked.com |
|---|---|
| Last Updated: | Sunday the 27th of July, 2008. |