Deviation from object-relational mapping (pySQLFace)

sulyokpeti at gmail.com sulyokpeti at gmail.com
Mon Oct 13 19:05:48 EDT 2008


On okt. 13, 10:33, Bruno Desthuilliers <bruno.
42.desthuilli... at websiteburo.invalid> wrote:
> sulyokp... at gmail.com a écrit :
>
> > I have made a simple python module to handle SQL databases:
> >https://fedorahosted.org/pySQLFace/wiki
> > Its goal to separate relational database stuff (SQL) from algorythmic
> > code (python). A SQLFace is a facade initialized with a configuration
> > file (XML). It provides callable command objects for each sql query.
> > The call substitutes template variables with its parameters, and
> > returns the result of the query.
> > I would like to get some opinions on this approach.
>
> First, I really don't see the point of XML for something as simple as
> specifying a SQL query and a couple metadata. This would be better done
> directly in Python using a metaclass, inheritance and a couple class
> attributes, ie:
>
> from SQLFace import Query, Statement
>
> class WbsTotal(Query):
>     expression="SELECT hours,wbs FROM wbs_total"
>     out = ['hours', 'wbs']
>
> class AddProject(Statement):
>      expression="""
>           INSERT INTO projects (project, description)
>           VALUES (%s, %s)
>           """
>      in_ = ['project', 'description']
>
> Also, I'd rather have Queries being iterators (delegating to the cursor)
> instead of calling cursor.fetchall and returning the whole result.
>
> My 2 cents
>
> NB : btw, did you have a look at SQLAlchemy's low-level
> python-relational integration part (*not* the 'orm' part) ?

Typo corrected.
I have just posted a message explaining the point of the separate XML
config file. Additionaly I do not like programming languages
intermixed with an other languages like SQL or HTML.
The result of the query is actually a list, so you have your iterator.
Although this fetchall solution is not suitable in case of a large
result set written to a stream. So I take this into consideration for
improving the query. Thanks.



More information about the Python-list mailing list