Giter VIP home page Giter VIP logo

Comments (4)

lunny avatar lunny commented on July 29, 2024
  1. I'm not sure if an engine can change database according to drivers' support. You should create a new engine.
  2. 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.
  3. ...好用就行。

from xorm.

 avatar commented on July 29, 2024

我稍微看了下,github.com/go-sql-driver/mysql驱动在OpenDb的时候,DNS URI可以不指定数据库名。如果一个数据库就得占用一个engine,维护一个连接池,在很多场景是很危险的。比如数据库比较多(垂直拆分,水平拆分)。我认为一个engine是基于一个数据库连接,而非跟database绑死。执行sql的时候,字符串连接上use xxx;不行么?
另:这只能算是sql helper,而非orm。
我个人比较喜欢sql helper,找到了这个,但我想它不能满足我的需求。

from xorm.

lunny avatar lunny commented on July 29, 2024

一个engine并非一个数据库连接。每个engine都内置有一个连接池。拆分成多个engine和用一个engine在性能和安全上应该是没有太大区别的。

如果底层的driver支持的话,xorm也是支持use xxx;的,可以通过engine.Exec("use xxx")来执行,但是我没有测试过各个驱动,所以无法给出确切的结论。

xorm本身支持两个层次使用,有Exec,Query,Sql等直接执行sql的函数,也可以使用其它方法来减少SQL的使用。
xorm后面还有二级缓存等等一些功能,这个已经超越了sql helper。

from xorm.

 avatar commented on July 29, 2024

既然不能change database,那么一个engine就相当于只使用一个database,即使有连接池。对于几十甚至上百个数据库来说,代价是很大的。要不就只能适用于中小型应用了。

from xorm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.