Skip to content

Commit 5f04817

Browse files
author
Bogdan Degtyariov
committed
WL 12791 New README.md and CONTRIBUTING.md
1 parent 3130a8d commit 5f04817

File tree

3 files changed

+187
-39
lines changed

3 files changed

+187
-39
lines changed

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contributing Guidelines
2+
3+
We love getting feedback from our users. Bugs and code contributions are great forms of feedback and we thank you for any bugs you report or code you contribute.
4+
5+
## Reporting Issues
6+
7+
Before reporting a new bug, please check first to see if a similar bug [exists](https://bugs.mysql.com/search.php).
8+
9+
Bug reports should be as complete as possible. Please try and include the following:
10+
11+
* complete steps to reproduce the issue
12+
* any information about platform and environment that could be specific to the bug
13+
* Specific version of the product you are using
14+
* Specific version of the server being used
15+
* C++ code to help reproduce the issue if possible
16+
17+
## Contributing Code
18+
19+
Contributing to this project is easy. You just need to follow these steps.
20+
21+
* Sign the Oracle Contributor Agreement. You can find instructions for doing that at [OCA Page](https://www.oracle.com/technetwork/community/oca-486395.html)
22+
* Develop your pull request
23+
* Make sure you are aware of the requirements for the project (i.e. don't require C++17 if we are supporting C++11 and higher)
24+
* Validate your pull request by including tests that sufficiently cover the functionality
25+
* Verify that the entire test suite passes with your code applied
26+
* Submit your pull request
27+
28+
## Running Tests
29+
30+
Any contributed code should pass our unit tests.
31+
To run the unit tests you need to perform the following steps:
32+
33+
* Build the Connector/C++ with the cmake option enabling unit tests (-DWITH_TESTS=1)
34+
* Run MySQL Server
35+
* Set the following environment variables:
36+
* XPLUGIN_PORT = <the port number of XPlugin in MySQL Server>
37+
* XLPIGIN_USER = <MySQL user name>
38+
* XPLUGIN_PASSWORD = <MySQL password>
39+
* In the OS command line enter the Connector/C++ build directory and run `ctest` utility
40+
41+
At the end of `ctest` run the result should indicate 100% tests passed.

README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# MySQL Connector/C++
2+
3+
This is a release of MySQL Connector/C++, [the C++ interface](https://dev.mysql.com/doc/dev/connector-cpp/8.0/) for communicating with MySQL servers.
4+
5+
For detailed information please visit the official [MySQL Connector/C++ documentation](https://dev.mysql.com/doc/dev/connector-cpp/8.0/).
6+
7+
## Licensing
8+
9+
Please refer to files README and LICENSE, available in this repository, and [Legal Notices in documentation](https://dev.mysql.com/doc/connector-cpp/8.0/en/preface.html) for further details.
10+
11+
## Download & Install
12+
13+
MySQL Connector/C++ can be installed from pre-compiled packages that can be downloaded from the [MySQL downloads page](https://dev.mysql.com/downloads/connector/cpp/).
14+
The process of installing of Connector/C++ from a binary distribution is described in [MySQL online manuals](https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-binary.html)
15+
16+
### Building from sources
17+
18+
MySQL Connector/C++ can be installed from the source. Please check [MySQL online manuals](https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-source.html)
19+
20+
### GitHub Repository
21+
22+
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.
23+
24+
## Sample Code
25+
26+
```
27+
#include <iostream>
28+
#include <mysqlx/xdevapi.h>
29+
30+
using ::std::cout;
31+
using ::std::endl;
32+
using namespace ::mysqlx;
33+
34+
35+
int main(int argc, const char* argv[])
36+
try {
37+
38+
const char *url = (argc > 1 ? argv[1] : "mysqlx://root@127.0.0.1");
39+
40+
cout << "Creating session on " << url
41+
<< " ..." << endl;
42+
43+
Session sess(url);
44+
45+
cout <<"Session accepted, creating collection..." <<endl;
46+
47+
Schema sch= sess.getSchema("test");
48+
Collection coll= sch.createCollection("c1", true);
49+
50+
cout <<"Inserting documents..." <<endl;
51+
52+
coll.remove("true").execute();
53+
54+
{
55+
DbDoc doc(R"({ "name": "foo", "age": 1 })");
56+
57+
Result add =
58+
coll.add(doc)
59+
.add(R"({ "name": "bar", "age": 2, "toys": [ "car", "ball" ] })")
60+
.add(R"({ "name": "bar", "age": 2, "toys": [ "car", "ball" ] })")
61+
.add(R"({
62+
"name": "baz",
63+
"age": 3,
64+
"date": { "day": 20, "month": "Apr" }
65+
})")
66+
.add(R"({ "_id": "myuuid-1", "name": "foo", "age": 7 })")
67+
.execute();
68+
69+
std::list<string> ids = add.getGeneratedIds();
70+
for (string id : ids)
71+
cout <<"- added doc with id: " << id <<endl;
72+
}
73+
74+
cout <<"Fetching documents..." <<endl;
75+
76+
DocResult docs = coll.find("age > 1 and name like 'ba%'").execute();
77+
78+
int i = 0;
79+
for (DbDoc doc : docs)
80+
{
81+
cout <<"doc#" <<i++ <<": " <<doc <<endl;
82+
83+
for (Field fld : doc)
84+
{
85+
cout << " field `" << fld << "`: " <<doc[fld] << endl;
86+
}
87+
88+
string name = doc["name"];
89+
cout << " name: " << name << endl;
90+
91+
if (doc.hasField("date") && Value::DOCUMENT == doc.fieldType("date"))
92+
{
93+
cout << "- date field" << endl;
94+
DbDoc date = doc["date"];
95+
for (Field fld : date)
96+
{
97+
cout << " date `" << fld << "`: " << date[fld] << endl;
98+
}
99+
string month = doc["date"]["month"];
100+
int day = date["day"];
101+
cout << " month: " << month << endl;
102+
cout << " day: " << day << endl;
103+
}
104+
105+
if (doc.hasField("toys") && Value::ARRAY == doc.fieldType("toys"))
106+
{
107+
cout << "- toys:" << endl;
108+
for (auto toy : doc["toys"])
109+
{
110+
cout << " " << toy << endl;
111+
}
112+
}
113+
114+
cout << endl;
115+
}
116+
cout <<"Done!" <<endl;
117+
}
118+
catch (const mysqlx::Error &err)
119+
{
120+
cout <<"ERROR: " <<err <<endl;
121+
return 1;
122+
}
123+
catch (std::exception &ex)
124+
{
125+
cout <<"STD EXCEPTION: " <<ex.what() <<endl;
126+
return 1;
127+
}
128+
catch (const char *ex)
129+
{
130+
cout <<"EXCEPTION: " <<ex <<endl;
131+
return 1;
132+
}
133+
134+
```
135+
136+
## Documentation
137+
138+
* [MySQL](http://www.mysql.com/)
139+
* [Connector/C++ API Reference](https://dev.mysql.com/doc/dev/connector-cpp/8.0/)
140+
141+
## Questions/Bug Reports
142+
143+
* [Discussion Forum](https://forums.mysql.com/list.php?167)
144+
* [Slack](https://mysqlcommunity.slack.com)
145+
* [Bugs](https://bugs.mysql.com)
146+

README.txt

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)