Use the Polypheny C++ driver to run SQL and MongoQL over the Prism query interface. The driver requires C++17 or later. Version 1.0.0 uses the Prism 2.2 definitions.
Run your first query
Start Polypheny-DB with a compatible Prism interface. Check the listener and port in the Interfaces view. This example uses plain TCP on 127.0.0.1:20590 and the local development account pa with an empty password. Use the connection settings for your instance.
Follow the build and Meson setup instructions to add the driver to your application. Save the following as main.cpp. The query runs in the relational public namespace and requires no tables.
#include <iostream>
#include "PolyphenyCPPDriver.h"
int main() {
Connection::Connection connection("127.0.0.1", "pa", "");
Connection::Cursor cursor(connection);
auto result = cursor.execute("sql", "SELECT CAST(42 AS INTEGER) AS answer", "public");
auto* rows = result->unwrap<Results::RelationalResult>();
for (auto row = rows->begin(); row != rows->end(); ++row) {
std::cout << (*row)[0].as_int32_t() << '\n';
}
}
The program prints 42. Keep the connection and cursor alive while handling results. C++ destroys the result before the cursor and connection when this program exits.
Continue with your data
- Querying covers SQL rows, MongoQL documents, namespace metadata, and server support for graph results.
- Prepared statements covers positional and named SQL parameters and batch execution.
- API reference lists the connection, transport, query, result and value APIs supported by the release.