C ++的持久解决方案(使用SQL数据库)?[英] Persistence solutions for C++ (with a SQL database)?

本文是小编为大家收集整理的关于C ++的持久解决方案(使用SQL数据库)?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我想知道使用SQL数据库的C ++有哪种持久解决方案?除了使用自定义SQL进行操作(并封装数据访问DAO或类似内容),还有其他(更通用的)解决方案吗?

喜欢一些通用库或框架(例如Hibernate&Co for Java和.net)还是其他? (我什至没有想到的东西也可以被建议)

编辑:是的,我正在寻找更多的ORM解决方案或类似于处理SQL查询以及表和对象之间的关系,而不是DB引擎本身.无论如何,感谢您的所有答案!

推荐答案

听起来您正在寻找一些ORM,因此您不必打扰手写的SQL代码.

有一个帖子在这里 cy++. p>

您还没有提及您正在编写的应用程序类型,如果它是桌面应用程序,移动应用程序,服务器应用程序.

手机:最好使用SQLite作为数据库引擎,因为它可以嵌入并具有小的占地面积.

桌面应用程序:您仍然应该在此处考虑使用SQLITE,但是您还可以选择大多数桌面应用程序可以始终连接到Internet,在这种情况下,您可能需要为此任务提供网络服务器.我建议使用Apache + MySQL + PHP并使用轻量级ORM,例如 outlet orm 和然后使用标准的HTTP帖子调用来访问您的资源.

服务器应用程序:您在这里还有更多选项,但我仍然建议使用Apache + MySQL + PHP + ORM,因为我发现在脚本语言中维护此层比C ++中要容易得多.

.

其他推荐答案

sqlite 很棒:它很快,稳定,证明,易于使用且易于使用和集成.

还有 metakit 尽管学习曲线有点陡峭.但是我在一个专业项目中成功使用了它.

其他推荐答案

mySQL连接器/C ++是JDBC 4.0

的C ++实现

使用MySQL连接器/C ++的参考客户是: - openoffice -mysql workbench

了解更多信息: http://forums.myssql.com/read.php? 167,221298

本文地址:https://www.itbaoku.cn/post/597619.html

问题描述

I'm wondering what kind of persistence solutions are there for C++ with a SQL database? In addition to doing things with custom SQL (and encapsulating the data access to DAOs or something similar), are there some other (more general) solutions?

Like some general libraries or frameworks (something like Hibernate & co for Java and .NET) or something else? (Something that I haven't even thought of can also be welcome to be suggested)

EDIT: Yep, I was searching more for an ORM solution or something similar to handle sql queries and the relationships between tables and objects than for the db engine itself. Thanks for all the answers anyway!

推荐答案

It sounds like you are looking for some ORM so that you don't have to bother with hand written SQL code.

There is a post here that goes over ORM solutions for C++.

You also did not mention the type of application you are writing, if it is a desktop application, mobile application, server application.

Mobile: You are best off using SQLite as your database engine because it can be embedded and has a small footprint.

Desktop App: You should still consider using SQLite here, but you also have the option with most desktop applications to have an always on connection to the internet in which case you may want to provide a network server for this task. I suggest using Apache + MySQL + PHP and using a lightweight ORM such as Outlet ORM, and then using standard HTTP post calls to access your resources.

Server App: You have many more options here but I still suggest using Apache + MySQL + PHP + ORM because I find it is much easier to maintain this layer in a script language than in C++.

其他推荐答案

SQLite is great: it's fast, stable, proven, and easy to use and integrate.

There is also Metakit although the learning curve is a bit steep. But I've used it with success in a professional project.

其他推荐答案

MySQL Connector/C++ is a C++ implementation of JDBC 4.0

The reference customers who use MySQL Connector/C++ are: - OpenOffice - MySQL Workbench

Learn more: http://forums.mysql.com/read.php?167,221298