An ORM Layer in Roundup

Roundup, an bug/issue tracker has a nice approach to ORM. It is written in Python, they have a file called where you define your database schema in Python. It then automatically generates the tables in MySQL, PostgreSql, Sqlite, or AnyDbm (you get to choose), and keeps them in sync with your schema when you change it!

I thought it was a standard feature of Python, but it appears to be a unique product of Roundup developers. They have a database-like structure called Hyper DB (I am not sure whether it is all in-memory or not), and a number of
“back-ends” that can map Hyper DB to a relational database (or a DBM).

One nice feature is that the database schema is stored as string in the Schema table. This string is in fact a Python dictionary, something like

       [ ('name', ''),
         ('order', '') ]),

        [ ('path', ''),
          ('viewcvs_url', ''),
          ('host', ''),
          ('name', '') ]),

Then they just do eval(schema) to get a Python data structure out of it and compare with the current schema. Quite clever, albeit fairly restricted in some places to Roundup-specific use.

Roundup itself, by the way, did not turn out to be that great a bug tracker: it is very flexible, but tweaking it (e.g. adding a field) requires too many changes in too many places, and it uses technologies that I am not that familiar with. such as TAL template language. But I am very impressed with the database capabilities. Will investigate it further.

Leave a Reply

Your email address will not be published. Required fields are marked *