Take the 2-minute tour ×

the requirement is to generate several classes which inherits the base ORM class, and this class may have several static properties like columns and other things, and little bit python expressions that can be eval at run time for small business logic,

my question is, it is feasible to use antlr for such kind of things, as I'm not much familiar with antlr but google suggested me to use antlr for python code generator...

please advice......

share|improve this question
add comment

1 Answer

I think you have misunderstood the point of the ANTLR project. ANTLR is a parser generator, which means roughly:

  • You create a grammer for a language of your choosing. This could well be python, or a hybrid of it.
  • You run it through ANTLR which gives you code in a number of Languages capable of parsing your language.

This is useful in generating custom scripting languages and the natural language processing domain, both of which are (effectively) related.

Your problem sounds more like you are trying to generate some python code to model a business situation for an enterprise application (loathe as I am to use that term). Rather than reinvent the wheel I suggest you take a look at existing frameworks for achieving this such as SQLAlchemy and Django, both of which provide a base ORM implementation and allow you to derive subclasses which represent your data and include processing logic.

If you are looking for a solution to generate this for you from a description such as UML, I am sure someone is trying to do this too.

share|improve this answer
+1 Parser Generator != ORM –  delnan Aug 9 '10 at 13:30
yes you are right, framework is already there with OSV and ORM, but its like an add-on for that framework, which would be either generated from excel or text file with validating parser. –  shahjapan Aug 9 '10 at 13:31
+1 - I think SQLAlchemy is what the OP is looking for –  Paul McGuire Aug 9 '10 at 21:04
No I know sqlAlchemy and Django both, what I want is to generate python class which has predefined structure but it should be generated from Excel so user can directly create classes and views and developers just need to write business logic code, so current framework provides views based on XML file and to create models we've predifned well working OSV and ORM, problem is how to convert xls->csv-->python module ! –  shahjapan Aug 11 '10 at 17:02
Ah I see. If you're trying to make generated data models I would honestly advice... not doing it. That is why you employ developers / sql people. Or else use UML class generators. Excel isn't really suited to this task - how do you validate what's been input? How do you match Excel fields to SQL fields. And what is the point of ORM when you go from database->abstract class model to talk to a database? The idea is you start with a model that is abstract from the database and go from there. I'd teach your people how to write classes or build a tool that does that directly. –  Antony Vennard Aug 12 '10 at 12:12
show 1 more comment

Your Answer


