使用本机python数据结构顺利构建sql。
mosql的Python项目详细描述
此文档的完整版本位于mosql.mosky.tw。
mosql-多于sql
它允许您使用通用的python数据结构来构建sql。这是 主要特点:
- 易学-一切都只是一个简单的python对象或sql关键字。 它的查询完全取决于所提供的结构。
- 安全-它防止从标识符和值中注入sql。
- 快速-它只是将Python数据结构转换为sql
它不仅仅是sql。
Mosql很优雅
这里我们有一本字典,其中包括一个人的信息:
>>> mosky = { ... 'person_id': 'mosky', ... 'name' : 'Mosky Liu', ... }
我们想把它插入到一个名为person的表中。使用mosql.query:
>>> from mosql.query import insert >>> print(insert('person', mosky)) INSERT INTO "person" ("person_id", "name") VALUES ('mosky', 'Mosky Liu')
检查The Common Queries — mosql.query是否 细节,或者有examples与真实交互 数据库。