-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
抽象化对SQL语句的操作 #26
Comments
帮忙改造一下,顺便让也学习一下~ |
审核结果的定义
审核结果集的定义
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
目前涉及到SQL语句的操作, 都是函数, 可以把这些操作抽象成一个个的 Engine
相当于 java 里的 Interface , 然后再继承这个Interface , 实现一个 MysqlEngine , 这样方便其它数据库比如 PG , oracle等的接入
统一了interface之后, 只要继承interface , 统一返回对象, 实现出来的对象就一定能适配到系统中.
比如有 查询方法叫 Query , 那么代码里只要 get_engine , 然后 SomeEngine.query ,就一定能得到预期的结果.
适配数据库时, 也就不需要更改主逻辑部分的代码. 更棒的是, 如果你不用这个引擎, 就不会import到那些库, 那么在你不用pg的时候, 不装pg相关的依赖也是可以的. 测试功能会更加简单, 尤其在一些依赖很难装的windows 机器上.
The text was updated successfully, but these errors were encountered: