SOCI - The C++ Database Access Library

Overview

SOCI - The C++ Database Access Library

GitHub release GitHub commits

Website SourceForge

Gitter Mailing Lists StackExchange

Build Status

Branches GitHub Actions AppVeyor-CI Documentation Coverity Scan
master Build Status Build status Docs Status Coverage
release/4.0 Build Status Build status Docs Status

History

Originally, SOCI was developed by Maciej Sobczak at CERN as abstraction layer for Oracle, a Simple Oracle Call Interface. Later, several database backends have been developed for SOCI, thus the long name has lost its practicality. Currently, if you like, SOCI may stand for Simple Open (Database) Call Interface or something similar.

"CERN is also a user of the SOCI library, which serves as a database access layer in some of the control system components."

-- Maciej Sobczak at Inspirel

License

SOCI library is distributed under the terms of the Boost Software License.

Requirements

Core:

  • C++ compiler
  • Boost C++ Libraries (optional, headers and Boost.DateTime)

Backend specific client libraries for:

  • DB2
  • Firebird
  • MySQL
  • ODBC with specific database driver
  • Oracle
  • PostgreSQL
  • SQLite 3

See documentation at soci.sourceforge.net for details

BSL © Maciej Sobczak and contributors.

Comments
  • Avoid exception from destructor while stack unwinding

    Avoid exception from destructor while stack unwinding

    Maciej notified me about discussion on SOCI at Linkedin C++ Professionals Group, where folks discussed that SOCI still suffers from potential of throwing from destructor while another exception is handled.

    Maciej suggested to fix it by checking std::uncaught_exception() in ref_counted_statement_base::dec_ref(), and if it returns true, the final_action() should not be called to avoid _any_ interactions with database.

    Core Category/Annoyance 
    opened by mloskot 39
  • Improve FindSoci.cmake

    Improve FindSoci.cmake

    The new version uses consistent spelling that matches the name of then module file (Soci instead of SOCI). In addition it delegates the handling of individual components to the standard cmake function and adds support for querying the SOCI version (from the version.h header file).

    CMake 
    opened by Krzmbrzl 31
  • Build failure with Oracle Instant Client 11.2.0.3.0

    Build failure with Oracle Instant Client 11.2.0.3.0

    Hello, I'm writing on behalf of the MacPorts package management system. We are trying to update our port of Oracle Instant Client from 10.2.0.4.0 to 11.2.0.3.0, but doing this causes soci to fail to build with Oracle support. I tested version 3.1.0 and 176805b886929d7f7df4f93b1eb987e6f4be0a1e from git with the same result. This is the error message:

    ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) for architecture x86_64
    

    We get the same error when trying to build TOra 2.1.3 with Oracle support.

    Here is the full build log. I'm on OS X 10.8.2 compiling with Xcode 4.6's version of clang ("Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)").

    Oracle 
    opened by ryandesign 30
  • Repair VC8 compile of test applications

    Repair VC8 compile of test applications

    Due to unsupported default param usage in macros and no qualified given _WIN32_WINNT version the test apps will not compile with some of Microsoft compilers. Exception Features used are only available if a minimum version is set due to conditional enabling in windows.h file (and sub required files)

    Category/Test Toolset/MSVC Toolset/MinGW 
    opened by hrabe 28
  • `soci` not found when adding as subproject

    `soci` not found when adding as subproject

    I can't seem to be able to add soci as a subproject.

    I have tried with ExternalProject_Add, and FetchContent but I can't figure out why I keep getting:

    CMake Error at src/test_app/CMakeLists.txt:21 (add_dependencies):
      The dependency target "soci" of target "test_app" does not exist.
    

    Project description

    My project structure is the following:

    └── src
        ├── CMakeLists.txt
        ├── cmake
        │   ├── soci.cmake
        │   └── spdlog.cmake
        ├── test_app
        │   └── CMakeLists.txt
        └── (...)
    

    src/CMakeLists.txt

    cmake_minimum_required(VERSION 3.11)
    
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    
    include(cmake/spdlog.cmake)
    include(cmake/soci.cmake)
    
    add_subdirectory(test_app)
    

    src/test_app/CMakeLists.txt

    cmake_minimum_required(VERSION 3.11)
    
    project(test_app LANGUAGES CXX)
    
    add_executable(test_app main.cpp)
    
    target_link_libraries(test_app PRIVATE
        spdlog
        SOCI::core
    )
    
    add_dependencies(test_app spdlog soci)
    

    spdlog.cmake

    cmake_minimum_required(VERSION 3.11)
    
    message(STATUS "Extern: spdlog v1.4.2")
    
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    
    include(FetchContent)
    
    FetchContent_Declare( spdlog
        GIT_REPOSITORY https://github.com/gabime/spdlog
        GIT_TAG v1.4.2
        GIT_SHALLOW ON
    )
    FetchContent_GetProperties(spdlog)
    if(NOT spdlog_POPULATED)
        set(SPDLOG_BUILD_EXAMPLE OFF)
        set(SPDLOG_BUILD_EXAMPLE_HO OFF)
        set(SPDLOG_BUILD_TESTS OFF)
        set(SPDLOG_BUILD_TESTS_HO OFF)
        set(SPDLOG_BUILD_BENCH OFF)
        set(SPDLOG_SANITIZE_ADDRESS OFF)
        set(SPDLOG_INSTALL ON)
        set(SPDLOG_FMT_EXTERNAL OFF)
        FetchContent_Populate(spdlog)
        add_subdirectory(
            ${spdlog_SOURCE_DIR}
            ${spdlog_BINARY_DIR}
            EXCLUDE_FROM_ALL)
    endif()
    

    soci.cmake

    cmake_minimum_required(VERSION 3.11)
    
    message(STATUS "Extern: SOCI pre4.0+git_blksail")
    
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    
    include(FetchContent)
    
    FetchContent_Declare( soci
        GIT_REPOSITORY https://github.com/SOCI/soci
        GIT_TAG master
        GIT_SHALLOW ON
    )
    FetchContent_GetProperties(soci)
    if(NOT soci_POPULATED)
        set(SOCI_STATIC ON)
        set(SOCI_SHARED ON)
        set(SOCI_TESTS OFF)
        # set(SOCI_ASAN OFF)
        set(SOCI_CXX11 ON)
        set(SOCI_LIBDIR lib)
        set(WITH_SQLITE3 ON)
        set(WITH_POSTGRESQL ON)
        set(WITH_BOOST OFF)
        set(WITH_DB2 OFF)
        set(WITH_ODBC OFF)
        set(WITH_ORACLE OFF)
        set(WITH_MYSQL OFF)
        set(SOCI_EMPTY OFF)
        FetchContent_Populate(soci)
        add_subdirectory(
            ${soci_SOURCE_DIR}
            ${soci_BINARY_DIR}
            EXCLUDE_FROM_ALL)
    endif()
    
    CMake 
    opened by msis 23
  • Replace type_ptr by shared_ptr and solve some issues

    Replace type_ptr by shared_ptr and solve some issues

    Replace type_ptr by shared_ptr that can be easily replaced by boost::shared_ptr

    Solve some issues encountered using sqlite3 backend

    Not tested with any other backend

    Core 
    opened by ArnaudD-FR 22
  • Commit odbc backend updates

    Commit odbc backend updates

    1. Fixed a bug in preparing a vector of strings for binding. The current implementation inserted an extra white character to the end of each string. This error shows up in SQL Server, not in MySQL (via ODBC).
    2. Added support for long long.
    3. Added two search paths to FindODBC.cmake.
    ODBC 
    opened by candychiu 22
  • "use" parameters additional functionality

    When developing with soci I tried to use the following:

    //tried to insert null as second parameter
    sql << "insert into test values( :int, :str )", use(1), use("",i_null); 
    

    which was not supported because use indicator was only implemented for non const scenario.

    I have also tried to call use with const char instead of std::string:

     //This was also not supported
    sql << "insert into test values( :str )", use("Hello");
    

    So I wrote some additional templates and functions in use.h to support the following cases: 1.) dbNull() function to use whenever we need to insert null value into database 2.) Support for const char* type 3.) Support for const char[N] type

    In order to enable the following scenarios I needed to modify use_container template to support some additional cases so bool isDataOwner template argument is added in order to detect whether use_container holds a referenced value or holds a copy of the value passed to use function.

    With this PR additional use scenarios are possible:

    //use const char[N] directly 
    sql << "insert into test values(:str)", use("Hello");
    
    //use const char* directly
    const char* value = "Hello";
    sql << "insert into test values(:str)", use(value);
    
    // use dbNull() instead of explicit indicator
    sql << "insert into test values(:str)", dbNull();
    // alternative to dbNull( value type is ignored in this case)
    sql << "insert into test values(:str)", use("",i_null);
    
    Core Category/Feature Status/Need-Feedback 
    opened by ravselj 21
  • Building of very first file fails with mingw

    Building of very first file fails with mingw

    With the most recent master checkout (70085e8a0a6d0d) building with mingw fails now at the very first file. Although I already got one ticket ( #338 ) about building problems with mingw, I have opened this one, because I assume this is just a minor, different, one line correction bug.

    C:\Users\klm\Downloads\soci_build>"C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\mi
    ngw32-make.exe"
    Scanning dependencies of target soci_core
    [  1%] Building CXX object src/core/CMakeFiles/soci_core.dir/backend-loader.cpp.
    obj
    C:\Users\klm\Downloads\soci\src\core\backend-loader.cpp:1:0: error: -fPIC ignore
    d for target (all code is position independent) [-Werror]
     //
     ^
    cc1plus.exe: all warnings being treated as errors
    src\core\CMakeFiles\soci_core.dir\build.make:54: recipe for target 'src/core/CMa
    keFiles/soci_core.dir/backend-loader.cpp.obj' failed
    mingw32-make[2]: *** [src/core/CMakeFiles/soci_core.dir/backend-loader.cpp.obj]
    Error 1
    CMakeFiles\Makefile2:125: recipe for target 'src/core/CMakeFiles/soci_core.dir/a
    ll' failed
    mingw32-make[1]: *** [src/core/CMakeFiles/soci_core.dir/all] Error 2
    Makefile:126: recipe for target 'all' failed
    mingw32-make: *** [all] Error 2
    
    CMake Toolset/MinGW 
    opened by Superlokkus 19
  • Issue #83 - get_affected_rows support for bulk operations

    Issue #83 - get_affected_rows support for bulk operations

    Here is the fix for the lack of info when calling statement::get_affected_rows() after bulk operations using postgresql backend. The other backends seem to already provide this info under this kind of use but I don't have the means to confirm that. The tests for get_affected_rows might confirm that.

    PostgreSQL 
    opened by ricardofandrade 19
  • Fix code writing to the database to work in any locale as well.

    Fix code writing to the database to work in any locale as well.

    This is similar to #238 but completes it by

    1. Doing the same thing in the other direction, i.e. when writing doubles to the database and not reading them.
    2. Doing the same changes in mysql and sqlite3 backends in addition to the postgresql one.
    Core Category/Annoyance 
    opened by vadz 18
MySQL Server, the world's most popular open source database, and MySQL Cluster, a real-time, open source transactional database.

Copyright (c) 2000, 2021, Oracle and/or its affiliates. This is a release of MySQL, an SQL database server. License information can be found in the

MySQL 8.6k Dec 26, 2022
A mini database for learning database

A mini database for learning database

Chuckie Tan 4 Nov 14, 2022
Tntdb is a c++-class-library for easy access to databases

Tntdb is a c++-class-library for easy access to databases

Tommi Mäkitalo 31 Aug 1, 2022
SpDB is a data integration tool designed to organize scientific data from different sources under the same namespace according to a global schema and to provide access to them in a unified form (views)

SpDB is a data integration tool designed to organize scientific data from different sources under the same namespace according to a global schema and to provide access to them in a unified form (views). Its main purpose is to provide a unified data access interface for complex scientific computations in order to enable the interaction and integration between different programs and databases.

YU Zhi 0 Jun 22, 2022
A hook for Project Zomboid that intercepts files access for savegames and puts them in an SQLite DB instead.

ZomboidDB This project consists of a library and patcher that results in file calls for your savegame(s) being transparently intercepted and redirecte

Oliver 7 Aug 27, 2022
Velox is a new C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.

Velox is a C++ database acceleration library which provides reusable, extensible, and high-performance data processing components

Facebook Incubator 2k Jan 8, 2023
The fastest database-library on Android OS.

Android SQLite3 NDK 封装 Demo下载 (操作:按钮新增 按钮查询 点按编辑 长按删除) 写在前面 sqlite3 开源、集成简单(现在的版本只有2个文件 sqlite3.h sqlite3.c) 这个库抽离自 Telegram 的开源代码、作者:DrKLO 我个人感觉 Tele

水银灯、 2 Dec 27, 2021
C++11 wrapper for the LMDB embedded B+ tree database library.

lmdb++: a C++11 wrapper for LMDB This is a comprehensive C++ wrapper for the LMDB embedded database library, offering both an error-checked procedural

D.R.Y. C++ 263 Dec 27, 2022
A friendly and lightweight C++ database library for MySQL, PostgreSQL, SQLite and ODBC.

QTL QTL is a C ++ library for accessing SQL databases and currently supports MySQL, SQLite, PostgreSQL and ODBC. QTL is a lightweight library that con

null 173 Dec 12, 2022
Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.

Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.

GitHub 482 Dec 31, 2022
dqlite is a C library that implements an embeddable and replicated SQL database engine with high-availability and automatic failover

dqlite dqlite is a C library that implements an embeddable and replicated SQL database engine with high-availability and automatic failover. The acron

Canonical 3.3k Jan 9, 2023
Nebula Graph is a distributed, fast open-source graph database featuring horizontal scalability and high availability

Nebula Graph is an open-source graph database capable of hosting super large scale graphs with dozens of billions of vertices (nodes) and trillions of edges, with milliseconds of latency.

vesoft inc. 834 Dec 24, 2022
DuckDB is an in-process SQL OLAP Database Management System

DuckDB is an in-process SQL OLAP Database Management System

DuckDB 7.8k Jan 3, 2023
YugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features

YugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features. It is best to fit for cloud-native OLTP (i.e. real-time, business-critical) applications that need absolute data correctness and require at least one of the following: scalability, high tolerance to failures, or globally-distributed deployments.

yugabyte 7.4k Jan 7, 2023
TimescaleDB is an open-source database designed to make SQL scalable for time-series data.

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.

Timescale 14.3k Jan 2, 2023
Beryl-cli is a client for the BerylDB database server

Beryl-cli is a client for the BerylDB database server. It offers multiple commands and is designed to be fast and user-friendly.

BerylDB 11 Oct 9, 2022
PolarDB for PostgreSQL (PolarDB for short) is an open source database system based on PostgreSQL.

PolarDB for PostgreSQL (PolarDB for short) is an open source database system based on PostgreSQL. It extends PostgreSQL to become a share-nothing distributed database, which supports global data consistency and ACID across database nodes, distributed SQL processing, and data redundancy and high availability through Paxos based replication. PolarDB is designed to add values and new features to PostgreSQL in dimensions of high performance, scalability, high availability, and elasticity. At the same time, PolarDB remains SQL compatibility to single-node PostgreSQL with best effort.

Alibaba 2.5k Dec 31, 2022
A MariaDB-based command line tool to connect to OceanBase Database.

什么是 OceanBase Client OceanBase Client(简称 OBClient) 是一个基于 MariaDB 开发的客户端工具。您可以使用 OBClient 访问 OceanBase 数据库的集群。OBClient 采用 GPL 协议。 OBClient 依赖 libobclie

OceanBase 51 Nov 9, 2022
A proxy server for OceanBase Database.

OceanBase Database Proxy TODO: some badges here OceanBase Database Proxy (ODP for short) is a dedicated proxy server for OceanBase Database. OceanBase

OceanBase 79 Dec 9, 2022