以可移植的方式使用 DB Api

发布于 2024-08-17 05:47:27 字数 283 浏览 2 评论 0原文

我需要开发某种应用程序并在其中使用数据库。

假设我目前想在 Windows 上开发它,但是,几个月后我可能必须将其迁移到 Linux。

我开始阅读一些相关内容,但无法找到我需要的内容。

是否有用于使用 DB 的通用/可扩展/标准 api?

我读到有 ODBC、JDBC、iOBDC、unixODBC 吗?为什么所有这些都存在?

有人可以帮助我理清思路并纠正这个问题吗?

编辑 - 我正在使用 C++ - 所以请建议这个方向,即使我会欣赏跨语言/跨平台的建议

I need to develop some kind of application and use DB in it.

Let's say i want to develop it over Windows currently, however, in a couple months i may have to migrate it to Linux.

I started reading a little bit about it, but couldn't get to point i needed.

Is there or isn't a generic/protable/standart api for using DB ?

I read there is ODBC,JDBC, iOBDC,unixODBC ? why all of these exist ?

Can someone help clearing and setting my head straight regarding the issue ?

Edit - I'm using C++ - so please advise to that direction, even though i'll appreciate inter-language/inter-platform recommendations

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丑丑阿 2024-08-24 05:47:27

有一堆用于通用数据库访问的 C++“包装”库,这是我的一些想法:

  • SOCI - 现代 C++ 语法,积极开发,与 boost 配合良好,支持多个后端
  • OTL - 仅标头(模板),非常轻量级

这两个都源于 Oracle 特定的工作,但现在至少支持几个其他数据库。
当然,您无法真正隐藏供应商差异,但这是一般的泄漏抽象法则

There's a bunch of C++ "wrapper" libraries for generic DB access, here's couple of top of my head:

  • SOCI - modern C++ syntax, active development, plays nice with boost, supports multiple backends
  • OTL - header-only (templates), very light-weight

Both of these grew out of Oracle-specific work, but support at least several other databases now.
Of course you can't really hide vendor differences, but that is general law of leaky abstractions.

两仪 2024-08-24 05:47:27

只需将 JDBC API 与 JDBC 驱动程序结合使用即可。不要使用 ODBC(桥接)驱动程序。

Just use the JDBC API in combination with a JDBC driver. Do not use the ODBC (bridge) driver.

追星践月 2024-08-24 05:47:27

如果您的数据库负载不是很重,我建议您使用SQLite。您只需要一个头文件和一个源文件(合并版本)。而且它非常便携。
我一直在 Windows 和 Linux 上使用它。

I recommend you using SQLite if your DB load is not very heavy. you need only one header file and one source file only(amalgamation version). and It's highly portable.
I have been using it on Windows and Linux.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文