! - )s/algorythmic/algorithmic!-) 回到维基...稍后再告诉你。Going back to the wiki... Tell you later. 首先,我真的没有看到XML的重点,因为 指定了一个SQL查询和几个元数据。这将更好地完成 使用元类,继承和几个类 属性直接在Python中,即: 来自SQLFace导入查询,声明 类WbsTotal(查询): 表达式=" SELECT小时,wbs FROM wbs_total" out = [''hours'',''wbs''] class AddProject(Statement): expression =""" INSERT INTO项目(项目,描述) VALUES(%s,%s) """ in_ = [''project'',''description''] 另外,我宁愿让查询成为迭代器(委托光标) 而不是调用cursor.fetchall并返回整个结果。 我的2美分 注意:顺便问一下,你看过SQLAlchemy'的低级 python-relational集成部分(*不是''orm''部分)?First, I really don''t see the point of XML for something as simple asspecifying a SQL query and a couple metadata. This would be better donedirectly in Python using a metaclass, inheritance and a couple classattributes, ie:from SQLFace import Query, Statementclass 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 centsNB : btw, did you have a look at SQLAlchemy''s low-levelpython-relational integration part (*not* the ''orm'' part) ? 这篇关于偏离对象关系映射(pySQLFace)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!