mysql/mysql-connector-cpp
소개
MySQL Connector/C++는 C++용 MySQL 데이터베이스 커넥터입니다. MySQL Server에 연결하는 C++ 및 C 애플리케이션을 개발할 수 있습니다.
데이터 및 분석측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalMySQL Connector/C++
This is a release of MySQL Connector/C++, the C++ interface for communicating with MySQL servers.
For detailed information please visit the official MySQL Connector/C++ documentation.
Licensing
Please refer to the README.txt and LICENSE.txt files, available in this repository, and Legal Notices in documentation for further details.
Contributing
We greatly appreciate feedback from our users, including bug reports and code contributions. Your input helps us improve, and we thank you for any issues you report or code you contribute. Please refer to the contributing document for additional information.
Download & Install
MySQL Connector/C++ can be installed from pre-compiled packages that can be downloaded from the MySQL downloads page. The process of installing of Connector/C++ from a binary distribution is described in MySQL online manuals
Current RPM distributions no longer include the mysql-connector-c++-compat package or the legacy JDBC ABI 9 libraries. Upgrades from pre-9.0 installations that require ABI 9 compatibility are unsupported by current RPM packages. Applications that depend on ABI 9 must retain a suitable older package or be rebuilt against a supported Connector/C++ ABI before upgrading. Existing compatibility package installations are not migrated automatically.
Build From Source
MySQL Connector/C++ can be installed from the source. Please check MySQL online manuals
GitHub Repository
This repository contains the MySQL Connector/C++ source code as per latest released version. You should expect to see the same contents here and within the latest released Connector/C++ package.
Sample Code
#include <iostream>
#include <mysqlx/xdevapi.h>
using ::std::cout;
using ::std::endl;
using namespace ::mysqlx;
int main(int argc, const char* argv[])
try {
const char *url = (argc > 1 ? argv[1] : "mysqlx://[email protected]");
cout << "Creating session on " << url
<< " ..." << endl;
Session sess(url);
cout <<"Session accepted, creating collection..." <<endl;
Schema sch= sess.getSchema("test");
Collection coll= sch.createCollection("c1", true);
cout <<"Inserting documents..." <<endl;
coll.remove("true").execute();
{
DbDoc doc(R"({ "name": "foo", "age": 1 })");
Result add =
coll.add(doc)
.add(R"({ "name": "bar", "age": 2, "toys": [ "car", "ball" ] })")
.add(R"({ "name": "bar", "age": 2, "toys": [ "car", "ball" ] })")
.add(R"({
"name": "baz",
"age": 3,
"date": { "day": 20, "month": "Apr" }
})")
.add(R"({ "_id": "myuuid-1", "name": "foo", "age": 7 })")
.execute();
std::list<string> ids = add.getGeneratedIds();
for (string id : ids)
cout <<"- added doc with id: " << id <<endl;
}
cout <<"Fetching documents..." <<endl;
DocResult docs = coll.find("age > 1 and name like 'ba%'").execute();
int i = 0;
for (DbDoc doc : docs)
{
cout <<"doc#" <<i++ <<": " <<doc <<endl;
for (Field fld : doc)
{
cout << " field `" << fld << "`: " <<doc[fld] << endl;
}
string name = doc["name"];
cout << " name: " << name << endl;
if (doc.hasField("date") && Value::DOCUMENT == doc.fieldType("date"))
{
cout << "- date field" << endl;
DbDoc date = doc["date"];
for (Field fld : date)
{
cout << " date `" << fld << "`: " << date[fld] << endl;
}
string month = doc["date"]["month"];
int day = date["day"];
cout << " month: " << month << endl;
cout << " day: " << day << endl;
}
if (doc.hasField("toys") && Value::ARRAY == doc.fieldType("toys"))
{
cout << "- toys:" << endl;
for (auto toy : doc["toys"])
{
cout << " " << toy << endl;
}
}
cout << endl;
}
cout <<"Done!" <<endl;
}
catch (const mysqlx::Error &err)
{
cout <<"ERROR: " <<err <<endl;
return 1;
}
catch (std::exception &ex)
{
cout <<"STD EXCEPTION: " <<ex.what() <<endl;
return 1;
}
catch (const char *ex)
{
cout <<"EXCEPTION: " <<ex <<endl;
return 1;
}
Documentation
Questions/Bug Reports
관련 프로젝트 살펴보기
불러오는 중…