知识卡片
数据库句柄管理连接池
sql.DB是连接池与查询入口,驱动实现具体数据库协议;它不是单独一条永久连接,也不是某个schema对象。sql.Open通常建立句柄而不证明服务器可达,Ping用于确认连接。构造失败后的资源释放和连接池预算仍需管理,不能只看Open没有报错。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Building a Cloud Native Service · 查看原书依据
Among the most ubiquitous members of the database/sql package is the sql.DB: Go’s primary database abstraction and entry point for creating statements and transactions, executing queries, and fetching results. While it doesn’t, as it name might suggest, map to any particular concept of a database or schema, it does do quite a lot of things
参考来源
- 位置:《Cloud Native Go》第05章《Building a Cloud Native Service》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch05.xhtml)
- 结论依据:sql.DB是连接池与查询入口,驱动实现具体数据库协议;它不是单独一条永久连接,也不是某个schema对象。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:Among the most ubiquitous members of the database/sql package is the sql.DB: Go’s primary database abstraction and entry point for creating statements and transactions, executing queries, and fetching results. While it doesn’t, as it name might suggest, map to any particular concept of a database or schema, it does do quite a lot of things