An RDBMS Backed Object Development Framework In Python







Backend usage details

What is PyBackend?

PyBackend is a relational database backed object development framework written in python and released under GNU Library General Public License. It allows object persistence through a relational database backend. You need not write SQL queries within your class to store or retrieve object-attributes. If your data model allows you to think attributes of your objects as columns of certain tables in your backend database, then PyBackend is for you.

PyBackend provides following functionalities:

  • It can store (as well as retrieve) attributes of objects in (from) a relational database supporting atomic transactions.
  • It allows you to map individual classes to corresponding databases. Hence an application can use multiple databases to populate its objects; all transparent to the application programmer.
  • It stores all information pertaining to the classes, attributes, databases, database authentication and number of connections per database etc. in a single text based configuration file.
  • It frees the application programmer from the task of creating and managing database connections. It creates such connections on demand. Maximum number of database connections for each database can be specified as a configuration option.
  • If your class interact with the database in more complex ways, you can execute your queries directly too. In this case you need not manage any database connections at all. You will get a handle to the correct database to which your class is mapped.
  • It can ensure atomic transactions even over multiple discrete operations; like over multiple HTTP/XMLRPC requests. Though not used in normal object management, this feature can be quite handy when you want to reserve a database connection exclusively for a particular use, even in a multi threaded application.

Project Origins

After designing few database oriented applications in python, I noticed that a large part of the code in every class was related to handling of SQL and database connections. Almost similar queries were being re-written in every other class to store or retrieve attributes of the objects. There were also problems in synchronizing data when two or more instances of same objects came into existence. It was a real pain to ensure proper callbacks in a multi-threaded application when one instance of the class changed its attribute and other one pointing to the same record in the backend had to reflect it in itself.

While looking for available options at that time I noticed that there was an RDBMS-OO mapping tool in perl but not in python; at least I couldn't find one. Then I decided to write it myself. Many months of work at very lazy pace brought up PyBackend. Now I have found few more similar tools in python. One of them is modeling which is inspired by Enterprise Object FrameworkTM of Apple.

Primary goal of PyBackend is to provide fast prototyping support and ease of use to programmers. PyBackend does not generate database schema or class-stubs. Though class-stub generators are in the todo list, database schema generators are not on the cards for the time being. If anyone writes those stuff, I would be glad to integrate them with PyBackend.

Project Developers

Developer E-mail
K Raghu Prasad raghuprasad at yahoo dot com