Comments (4)
- I'm not sure if an engine can change database according to drivers' support. You should create a new engine.
- Struct don't support tag because Golang don't provide. If you want to change the name mapping rule, you can implement your xorm.IMapper. Generally, Table method is provided for many tables which have the same struct.
- ...好用就行。
from xorm.
我稍微看了下,github.com/go-sql-driver/mysql驱动在OpenDb的时候,DNS URI可以不指定数据库名。如果一个数据库就得占用一个engine,维护一个连接池,在很多场景是很危险的。比如数据库比较多(垂直拆分,水平拆分)。我认为一个engine是基于一个数据库连接,而非跟database绑死。执行sql的时候,字符串连接上use xxx;不行么?
另:这只能算是sql helper,而非orm。
我个人比较喜欢sql helper,找到了这个,但我想它不能满足我的需求。
from xorm.
一个engine并非一个数据库连接。每个engine都内置有一个连接池。拆分成多个engine和用一个engine在性能和安全上应该是没有太大区别的。
如果底层的driver支持的话,xorm也是支持use xxx;
的,可以通过engine.Exec("use xxx")来执行,但是我没有测试过各个驱动,所以无法给出确切的结论。
xorm本身支持两个层次使用,有Exec,Query,Sql等直接执行sql的函数,也可以使用其它方法来减少SQL的使用。
xorm后面还有二级缓存等等一些功能,这个已经超越了sql helper。
from xorm.
既然不能change database,那么一个engine就相当于只使用一个database,即使有连接池。对于几十甚至上百个数据库来说,代价是很大的。要不就只能适用于中小型应用了。
from xorm.
Related Issues (20)
- sync2不支持同步mysql中MEMORY引擎的数据表V0.7.0
- Invalid object name 'SYS.INDEXES' on SQL Server case sensitive collate HOT 1
- CTE (Common Table Expression) with aliases support
- 事务无法执行afterClosure HOT 1
- go mod download get stuck at xorm.io/core HOT 2
- lost table name with session when insert multiple Slice
- xorm mock CURD HOT 2
- [xorm.NewEngine] I gave wrong 'dataSourceName' but can't panic the error HOT 2
- 文档的问题 HOT 1
- SQLite to mssql dump
- undefined: builder.StringBuilder HOT 3
- Oracle Dialect Quote Brackets HOT 1
- Mysql split-table HOT 2
- driver.Valuer not checked on Insert() HOT 1
- Add support for vertica
- Avoid varargs for batch operations HOT 1
- go fmt go file warning HOT 1
- how to use force index when construct session HOT 2
- mysql5.7版本中json类型的数据插入空数组,数据为null
- how to open session autoclose flag with xorm.engine HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xorm.