{"id":15023882,"url":"https://github.com/sap/odbc-cpp-wrapper","last_synced_at":"2026-02-25T21:05:38.768Z","repository":{"id":37977406,"uuid":"168746934","full_name":"SAP/odbc-cpp-wrapper","owner":"SAP","description":"An object-oriented C++-wrapper of the ODBC API","archived":false,"fork":false,"pushed_at":"2025-03-24T14:08:34.000Z","size":129,"stargazers_count":49,"open_issues_count":2,"forks_count":26,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-05T13:13:36.467Z","etag":null,"topics":["cpp","odbc-api","open-source"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-01T19:07:04.000Z","updated_at":"2025-04-04T03:38:39.000Z","dependencies_parsed_at":"2024-09-24T21:42:36.977Z","dependency_job_id":null,"html_url":"https://github.com/SAP/odbc-cpp-wrapper","commit_stats":{"total_commits":39,"total_committers":6,"mean_commits":6.5,"dds":0.5641025641025641,"last_synced_commit":"190b030035d2030d52d0a6ad1a5846f606c1897b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fodbc-cpp-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fodbc-cpp-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fodbc-cpp-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fodbc-cpp-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP","download_url":"https://codeload.github.com/SAP/odbc-cpp-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247632909,"owners_count":20970240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","odbc-api","open-source"],"created_at":"2024-09-24T19:59:34.380Z","updated_at":"2026-02-25T21:05:38.723Z","avatar_url":"https://github.com/SAP.png","language":"C++","readme":"# C++ Wrapper for ODBC\n\n[![REUSE status](https://api.reuse.software/badge/github.com/SAP/odbc-cpp-wrapper)](https://api.reuse.software/info/github.com/SAP/odbc-cpp-wrapper)\n\nodbc-cpp-wrapper is an object-oriented C++-wrapper of the ODBC API. It takes\ncare of\n - managing the lifetime of ODBC resources,\n - allocating and managing resources needed for ODBC operations and\n - converting ODBC errors to exceptions and throwing them.\n\nThe odbc-cpp-wrapper API attempts to make usage of ODBC as simple as possible.\nThe API was designed to make wrong usage almost impossible and to ensure proper\nobject lifetime management.\n\nodbc-cpp-wrapper was originally developed for exchanging spatial data with\ndatabases. It focuses on batch operations of variable-sized data, which is not\nvery well supported by other ODBC wrappers.\n\n## Requirements\n\nTo build odbc-cpp-wrapper you need\n - A C++-11-standard-compliant compiler\n - [The Git command line client](https://git-scm.com/)\n - [CMake 3.12 or newer](https://cmake.org/)\n\nOn Linux platforms you additionally need\n - [unixODBC](http://www.unixodbc.org/)\n\nTo generate the API's documentation, you need\n - [Doxygen 1.8.0 or later](http://www.doxygen.nl/)\n\n\n## Building and Installation\n\n### Linux\n\n- Clone the repository:\n    ```\n    git clone https://github.com/SAP/odbc-cpp-wrapper.git\n    ```\n\n- Create a build directory and change to it:\n    ```\n    mkdir odbc-cpp-wrapper/build \u0026\u0026 cd odbc-cpp-wrapper/build\n    ```\n\n- Create the makefiles with CMake:\n    ```\n    cmake ..\n    ```\n\n- Build the library:\n    ```\n    make -j \u003cnumber of parallel build jobs\u003e\n    ```\n\n    The build will create a shared library `libodbccpp.so` and a static library `libodbccpp_static.a`.\n\n- To build the documentation (optional):\n    ```\n    make doc\n    ```\n\n    The mainpage of the documentation can be found at `doc/html/index.html`.\n\n- Install the library:\n    ```\n    sudo make install\n    ```\n\n    This will install the library and header files. CMake will install them to `usr/local/lib` and `usr/local/include` by default. If you prefer different locations, you can set CMake's install prefix to a different path. See\nhttps://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html for details.\n\n\n### Windows\n\n- Clone the repository:\n    ```\n    git clone https://github.com/SAP/odbc-cpp-wrapper.git\n    ```\n\n- Create a build directory and change to it:\n    ```\n    mkdir odbc-cpp-wrapper\\build \u0026\u0026 cd odbc-cpp-wrapper\\build\n    ```\n\n#### Visual Studio 2015 and later\n\n- Generate a Visual Studio solution\n    ```\n    cmake ..\n    ```\n\n    You can then open the `odbccpp.sln` file and build the desired targets in Visual Studio.\n\n#### MSBuild (nmake)\n\n- Start the Visual Studio Native Tools Command Prompt for the desired target and change the directory to the build directory. Create the makefiles for nmake:\n    ```\n    cmake -G \"NMake Makefiles\" ..\n    ```\n\n    \u003e Optionally you can use CMAKE_BUILD_TYPE to define if you'd like to build a Debug or Release build. See\nhttps://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html for details.\n\n- Build the library:\n    ```\n    nmake\n    ```\n\n    The build will create a dynamic link library `odbccpp.dll` and a static library `odbccpp_static.lib`.\n\n- Build the documentation (optional):\n    ```\n    nmake doc\n    ```\n\n    The mainpage of the documentation can be found at `doc\\html\\index.html`.\n\n- Install the library (optional):\n    ```\n    nmake install\n    ```\n\n    This will install the library and header files. CMake will install them to `C:\\Program Files\\odbccpp` by default. If you prefer a different location, you can set CMake's install prefix to a different path. See\nhttps://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html for details.\n\n\n## Using the library\n\nYou can just link against the shared/dynamic or the static library. If you are linking against the static library, you have to additionally define `ODBC_STATIC` when compiling.\n\nUsage of the library should be pretty straight-forward if you are familiar with ODBC and/or other database connectors.\n\n### Example\n\nThe following code gives an example how working with odbc-cpp-wrapper looks like. It connects to a database, batch inserts two rows and executes a query.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003codbc/Connection.h\u003e\n#include \u003codbc/Environment.h\u003e\n#include \u003codbc/Exception.h\u003e\n#include \u003codbc/PreparedStatement.h\u003e\n#include \u003codbc/ResultSet.h\u003e\n\nint main()\n{\n    try\n    {\n        odbc::EnvironmentRef env = odbc::Environment::create();\n\n        odbc::ConnectionRef conn = env-\u003ecreateConnection();\n        conn-\u003econnect(\"DSN\", \"user\", \"pass\");\n        conn-\u003esetAutoCommit(false);\n\n        odbc::PreparedStatementRef psInsert =\n            conn-\u003eprepareStatement(\"INSERT INTO TAB (ID, DATA) VALUES (?, ?)\");\n        psInsert-\u003esetInt(1, 101);\n        psInsert-\u003esetCString(2, \"One hundred one\");\n        psInsert-\u003eaddBatch();\n        psInsert-\u003esetInt(1, 102);\n        psInsert-\u003esetCString(2, \"One hundred two\");\n        psInsert-\u003eaddBatch();\n        psInsert-\u003eexecuteBatch();\n        conn-\u003ecommit();\n\n        odbc::PreparedStatementRef psSelect =\n            conn-\u003eprepareStatement(\"SELECT ID, DATA FROM TAB WHERE ID \u003e ?\");\n        psSelect-\u003esetInt(1, 100);\n        odbc::ResultSetRef rs = psSelect-\u003eexecuteQuery();\n        while (rs-\u003enext())\n        {\n            std::cout \u003c\u003c rs-\u003egetInt(1) \u003c\u003c \", \" \u003c\u003c rs-\u003egetString(2) \u003c\u003c std::endl;\n        }\n    }\n    catch (const odbc::Exception\u0026 e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n    }\n}\n```\n\n## How to obtain support\n\nIf you experience issues with using the library, please file a report in the GitHub bug tracking system.\n\n\n## License\n\nCopyright 2019-2021 SAP SE or an SAP affiliate company and odbc-cpp-wrapper contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Please note the GPLv2 Combination Exception for the Apache 2 License! Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/odbc-cpp-wrapper).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fodbc-cpp-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap%2Fodbc-cpp-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fodbc-cpp-wrapper/lists"}