TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SqlAlchemy: ORM vs. Core expression language

2 点作者 Jaigus大约 12 年前
I'm in the process of writing a forum-like discussion component for a larger web application, and I am debating on whether or not I should use the full sqlalchemy ORM, or just the expression language. Using the expression language(the underlying part of sqlalchemy which the ORM is built upon), I planned to take a general table data gateway approach (http://martinfowler.com/eaaCatalog/tableDataGateway.html), creating simple and light-weight data-access-objects (e.g. UserGate, TopicGate, PostGate, etc) that will serve as the data-access layer.<p>The expression language protects against injection attacks, handles connection pooling, and also provides a nice way of generating the sql queries (e.g. usergate.select(whereclause=(usergate.c.id == userid)).execute() ). However, this approach will certainly necessitate more boilerplate code; I am wondering if this is acceptable since it will use much less internal function calls than the ORM.<p>I'd greatly appreciate some feedback, especially from people who have used sqlalchemy core to implement a custom data-access layer.<p>I read this article, but didn't get that much information from it tbh: http://stackful-dev.com/discovering-sqlalchemy-core-the-relational-nosql-api-for-python.html

暂无评论

暂无评论