SQLite Wrapper gesucht



  • Guten Morgen,
    gibt es einen C++ Wrapper für SQLite, welcher in der Lage ist auch mit verschlüsselten Datenbanken zu arbeiten und zusätzlich noch unter einer OpenSource, MIT etc. Lizenz steht?



  • @Zhavok Vlt ist das was für dich: http://soci.sourceforge.net



  • @Schlangenmensch das sieht schonmal ganz interessant aus 👍🏻 . Muss nur noch herausfinden ob das auch verschlüsselte sqlite db's unterstützt. Den sqlite Wrapper gibt's viele, allerdings ist die Unterstützung von Verschlüsselung nicht so selbstverständlich wie ich angenommen hatte.



  • @Zhavok Tut es, verwende ich zusammen mit einer verschlüsselten SQLite DB 😉



  • @Schlangenmensch Hervorragend 👍🏻. Genau was ich gesucht habe und sogar noch besser. Nun kämpfe ich nur noch mit CMake damit ichs builden kann und schon sollte ich es nutzen können 😂



  • Ok, ich gebs auf. Habe jetzt zwei komplette Tage damit verbracht SOCI unter Windows mit CMake zum laufen zu bekommen. Ich bekomme es absolut nicht hin^^



  • @Zhavok Wo legt denn das Problem? Bei uns läuft das auch auf Windows. Ich kann am Montag mal gucken, wie wir das konfiguriert haben, vlt hilft das.



  • Also es geht eigentlich gehts schon beim builden los. Ich gehe also ins Verzeichnis von soci und führe folgendes aus:

    C:\CPP\Additional Includes\soci>cmake -S . -B build -DWITH_SQLITE3=ON -DWITH_BOOST=OFF
    -- Building for: Visual Studio 16 2019
    -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.17763.
    -- The C compiler identification is MSVC 19.25.28614.0
    -- The CXX compiler identification is MSVC 19.25.28614.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Looking for _M_AMD64
    -- Looking for _M_AMD64 - found
    -- Looking for _M_IX86
    -- Looking for _M_IX86 - not found
    -- Configuring SOCI:
    -- SOCI_VERSION                             = 4.0.0
    -- SOCI_ABI_VERSION                         = 4_0
    -- SOCI_SHARED                              = ON
    -- SOCI_STATIC                              = ON
    -- SOCI_TESTS                               = ON
    -- SOCI_ASAN                                = OFF
    -- SOCI_CXX11                               = OFF
    -- LIB_SUFFIX                               = 64
    -- Looking for SOCI dependencies:
    -- Threads:
    -- CMAKE_THREAD_LIBS_INIT                   =
    -- Boost: disabled, since WITH_BOOST=OFF
    -- MySQL:
    -- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
    -- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION - Failed
    -- Found MySQL: C:/Program Files/MySQL/MySQL Server 8.0/include, C:/Program Files/MySQL/MySQL Server 8.0/lib/libmysql.lib
    -- MySQL Embedded not found.
    -- MYSQL_INCLUDE_DIR                        = C:/Program Files/MySQL/MySQL Server 8.0/include
    -- MYSQL_LIBRARIES                          = C:/Program Files/MySQL/MySQL Server 8.0/lib/libmysql.lib
    -- ODBC:
    -- ODBC_INCLUDE_DIR                         =
    -- ODBC_LIBRARIES                           = odbc32.lib
    -- Oracle:
    -- ORACLE_HOME=
    CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
      The package name passed to `find_package_handle_standard_args` (ORACLE)
      does not match the name of the calling package (Oracle).  This can lead to
      problems in calling code that expects `find_package` result variables
      (e.g., `_FOUND`) to follow a certain pattern.
    Call Stack (most recent call first):
      cmake/modules/FindOracle.cmake:84 (find_package_handle_standard_args)
      cmake/dependencies/Oracle.cmake:3 (find_package)
      cmake/SociDependencies.cmake:79 (include)
      CMakeLists.txt:76 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- None of the supported Oracle versions (19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
    -- WARNING: Oracle libraries not found, some features will be disabled.
    -- PostgreSQL:
    -- WARNING: PostgreSQL libraries not found, some features will be disabled.
    -- SQLite3:
    CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
      The package name passed to `find_package_handle_standard_args` (SQLITE3)
      does not match the name of the calling package (SQLite3).  This can lead to
      problems in calling code that expects `find_package` result variables
      (e.g., `_FOUND`) to follow a certain pattern.
    Call Stack (most recent call first):
      cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
      cmake/dependencies/SQLite3.cmake:3 (find_package)
      cmake/SociDependencies.cmake:79 (include)
      CMakeLists.txt:76 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- SQLITE3_INCLUDE_DIR                      = C:/CPP/Additional Includes/SQLite3/include
    -- SQLITE3_LIBRARIES                        = C:/CPP/Additional Includes/SQLite3/lib/sqlite3.lib
    -- Firebird:
    -- SOCI_FIREBIRD_EMBEDDED                   = OFF
    -- WARNING: Firebird libraries not found, some features will be disabled.
    -- DB2:
    -- WARNING: DB2 libraries not found, some features will be disabled.
    -- Configuring SOCI core library:
    -- SOCI_CORE_TARGET                         = soci_core
    -- SOCI_CORE_TARGET_OUTPUT_NAME             = soci_core_4_0
    -- SOCI_CORE_DEPS_LIBS                      =
    -- SOCI_CORE_INCLUDE_DIRS                   = C:/CPP/Additional Includes/soci/build C:/CPP/Additional Includes/soci/include C:/CPP/Additional Includes/soci/build/include C:/CPP/Additional Includes/soci/include/private C:/CPP/Additional Includes/soci/build/src/core
    -- WITH_BOOST                               = OFF
    -- COMPILE_DEFINITIONS                      = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF SOCI_LIB_PREFIX="soci_" SOCI_LIB_SUFFIX=".dll" SOCI_DEBUG_POSTFIX=""
    --
    -- Configuring SOCI backend libraries:
    -- Found MySQL: C:/Program Files/MySQL/MySQL Server 8.0/include, C:/Program Files/MySQL/MySQL Server 8.0/lib/libmysql.lib
    -- MySQL Embedded not found.
    -- ORACLE_HOME=
    CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
      The package name passed to `find_package_handle_standard_args` (ORACLE)
      does not match the name of the calling package (Oracle).  This can lead to
      problems in calling code that expects `find_package` result variables
      (e.g., `_FOUND`) to follow a certain pattern.
    Call Stack (most recent call first):
      cmake/modules/FindOracle.cmake:84 (find_package_handle_standard_args)
      src/backends/CMakeLists.txt:17 (find_package)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- None of the supported Oracle versions (19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
    CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
      The package name passed to `find_package_handle_standard_args` (SQLITE3)
      does not match the name of the calling package (SQLite3).  This can lead to
      problems in calling code that expects `find_package` result variables
      (e.g., `_FOUND`) to follow a certain pattern.
    Call Stack (most recent call first):
      cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
      src/backends/CMakeLists.txt:17 (find_package)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- Empty - SOCI backend skeleton for new backends development
    -- SOCI_EMPTY                               = ON
    -- SOCI_EMPTY_TARGET                        = soci_empty
    -- SOCI_EMPTY_OUTPUT_NAME                   = soci_empty_4_0
    -- SOCI_EMPTY_COMPILE_DEFINITIONS           = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
    -- SOCI_EMPTY_INCLUDE_DIRECTORIES           = C:/CPP/Additional Includes/soci/build C:/CPP/Additional Includes/soci/include C:/CPP/Additional Includes/soci/build/include C:/CPP/Additional Includes/soci/include/private C:/CPP/Additional Includes/soci/include/private
    -- MySQL - SOCI backend for MySQL
    -- SOCI_MYSQL                               = ON
    -- SOCI_MYSQL_TARGET                        = soci_mysql
    -- SOCI_MYSQL_OUTPUT_NAME                   = soci_mysql_4_0
    -- SOCI_MYSQL_COMPILE_DEFINITIONS           = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
    -- SOCI_MYSQL_INCLUDE_DIRECTORIES           = C:/CPP/Additional Includes/soci/build C:/CPP/Additional Includes/soci/include C:/CPP/Additional Includes/soci/build/include C:/CPP/Additional Includes/soci/include/private C:/CPP/Additional Includes/soci/include/private C:/Program Files/MySQL/MySQL Server 8.0/include
    -- ODBC - SOCI backend for ODBC
    -- SOCI_ODBC                                = ON
    -- SOCI_ODBC_TARGET                         = soci_odbc
    -- SOCI_ODBC_OUTPUT_NAME                    = soci_odbc_4_0
    -- SOCI_ODBC_COMPILE_DEFINITIONS            = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
    -- SOCI_ODBC_INCLUDE_DIRECTORIES            = C:/CPP/Additional Includes/soci/build C:/CPP/Additional Includes/soci/include C:/CPP/Additional Includes/soci/build/include C:/CPP/Additional Includes/soci/include/private C:/CPP/Additional Includes/soci/include/private
    -- SQLite3 - SOCI backend for SQLite 3
    -- SOCI_SQLITE3                             = ON
    -- SOCI_SQLITE3_TARGET                      = soci_sqlite3
    -- SOCI_SQLITE3_OUTPUT_NAME                 = soci_sqlite3_4_0
    -- SOCI_SQLITE3_COMPILE_DEFINITIONS         = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
    -- SOCI_SQLITE3_INCLUDE_DIRECTORIES         = C:/CPP/Additional Includes/soci/build C:/CPP/Additional Includes/soci/include C:/CPP/Additional Includes/soci/build/include C:/CPP/Additional Includes/soci/include/private C:/CPP/Additional Includes/soci/include/private C:/CPP/Additional Includes/SQLite3/include
    --
    -- Configuring SOCI tests:
    -- SOCI_EMPTY_TEST_CONNSTR                  = dummy
    -- SOCI_MYSQL_TEST_CONNSTR                  = db=soci_test
    -- SOCI_ODBC_TEST_ACCESS_CONNSTR            = FILEDSN=C:/CPP/Additional Includes/soci/tests/odbc/test-access.dsn
    -- SOCI_ODBC_TEST_MSSQL_CONNSTR             = FILEDSN=C:/CPP/Additional Includes/soci/tests/odbc/test-mssql.dsn
    -- SOCI_ODBC_TEST_MYSQL_CONNSTR             = FILEDSN=C:/CPP/Additional Includes/soci/tests/odbc/test-mysql.dsn
    -- SOCI_ODBC_TEST_POSTGRESQL_CONNSTR        = FILEDSN=C:/CPP/Additional Includes/soci/tests/odbc/test-postgresql-win64.dsn
    -- ODBC DB2 test disabled.
    -- SOCI_SQLITE3_TEST_CONNSTR                = :memory:
    --
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/CPP/Additional Includes/soci/build
    

    Dabei macht mich zum Beispiel folgendes stutzig:

    The package name passed to `find_package_handle_standard_args` (SQLITE3)
      does not match the name of the calling package (SQLite3).  This can lead to
      problems in calling code that expects `find_package` result variables
      (e.g., `_FOUND`) to follow a certain pattern.
    


  • @Zhavok sagte in SQLite Wrapper gesucht:

    cmake -S . -B build -DWITH_SQLITE3=ON -DWITH_BOOST=OFF
    
    cmake -S . -B build -DWITH_SQLite3=ON -DWITH_BOOST=OFF
    

    ?



  • @Swordfish sagte in SQLite Wrapper gesucht:

    cmake -S . -B build -DWITH_SQLite3=ON -DWITH_BOOST=OFF

    Die Fehlermeldung bleibt leider



  • @Zhavok schade.



  • Das sind doch nur Warnungen, keine Fehler.

    -- Building for: Visual Studio 16 2019
    ...
    -- Build files have been written to: C:/CPP/Additional Includes/soci/build

    Ist denn dort keine Projektdatei für VS 2019 (*.sln bzw. *.vcproj)?
    s.a. SOCI Installation "Running CMake on Windows", d.h. noch msbuild.exe SOCI.sln aufrufen.



  • Doch ist es und ich habs gleich via

    cmake --build build
    

    gebaut.
    Bis auf paar Warnungen und Linkerfehler ist es auch komplett durchgelaufen und alle targets wurden gebaut. Fande die Fehlermeldung jetzt trotzdem etwas beunruhigend. Kann ja morgen noch mal schreiben wo ich danach Probleme hatte.



  • Nachdem ich also wie geschrieben soci gebuilded hatte, hab ichs erstmal ganz simpel versucht an einem Testprojekt und dazu sah mein CMake-Script so aus:

    cmake_minimum_required(VERSION 3.17)
    
    project(SqliteTest)
    
    add_executable(SqliteTest)
    add_subdirectory(src)
    
    find_package(Soci)
    target_link_libraries(SqliteTest soci_core soci_sqlite3)
    

    Ich bekam den Fehler:

    "soci/soci.h": No such file or directory 
    

    weshalb ich noch noch target_include_directories ergänzte:

    cmake_minimum_required(VERSION 3.17)
    
    project(SqliteTest)
    
    add_executable(SqliteTest)
    add_subdirectory(src)
    
    
    find_package(Soci)
    target_include_directories(SqliteTest PUBLIC "C:/CPP/Additional Includes/soci/include")
    target_link_libraries(SqliteTest soci_core soci_sqlite3)
    

    Daraufhin bekam ich dann die Fehlermeldung:

    "sqlite3.h": No such file or directory
    

    Draufhin ergännzte ich also noch target_include_directories für SQLite:

    cmake_minimum_required(VERSION 3.17)
    
    project(SqliteTest)
    
    add_executable(SqliteTest)
    add_subdirectory(src)
    
    
    find_package(Soci)
    target_include_directories(SqliteTest PUBLIC "C:/CPP/Additional Includes/soci/include")
    target_include_directories(SqliteTest PUBLIC "C:/CPP/Additional Includes/SQLite3/include")
    target_link_libraries(SqliteTest soci_core soci_sqlite3)
    

    Ins stocken gekommen bin ich dann beim linken durch den Fehler:

    LINK : fatal error LNK1104: Datei "soci_core.lib" kann nicht geöffnet werden.
    

    Obwohl die soci_core.lib eigentlich vorhanden ist in "C:\CPP\Additional Includes\soci\build\lib\Debug".
    Schön ist das Ganze aber so oder so nicht, da ich eigentlich keine absoluten Pfade in CMake mag^^.



  • @Zhavok sagte in SQLite Wrapper gesucht:

    Obwohl die soci_core.lib eigentlich vorhanden ist in "C:\CPP\Additional Includes\soci\build\lib\Debug".

    Und woher soll der Linker das wissen?



  • Ich hätte gedacht, dass wenn find_package Soci findet, es beim linken doch dann auch die Unterverzeichnisse mit durchschauen müsste?



  • @Schlangenmensch hast du auf Arbeit noch etwas herausfinden kommen?



  • Sorry, ich bin gestern nicht dazu gekommen,

    wir bauen soci so (Debug Variante, Release analog):

    cmake -G "Visual Studio 15" ^
        -DWITH_BOOST=OFF ^
        -DWITH_BOOST=OFF ^
        -DSOCI_SHARED=OFF ^
        -DWITH_DB2=OFF ^
        -DWITH_FIREBIRD=OFF ^
        -DWITH_MYSQL=OFF ^
        -DWITH_ODBC=OFF ^
        -DWITH_ORACLE=OFF ^
        -DWITH_POSTGRESQL=OFF ^
        -DWITH_SQLITE3=ON ^
        -DSOCI_EMPTY=ON ^
        -DSOCI_DB2=OFF ^
        -DSOCI_FIREBIRD=OFF ^
        -DSOCI_MYSQL=OFF ^
        -DSOCI_ODBC=OFF ^
        -DSOCI_ORACLE=OFF ^
        -DSOCI_POSTGRESQL=OFF ^
        -DSOCI_SQLITE3=ON ^
        -DSQLITE3_INCLUDE_DIR=%sqlite_include_dir% ^
        -DSQLITE3_LIBRARY=%sqlite_library_path%\libsqlite3.lib ^
        -DCMAKE_INSTALL_PREFIX=%soci_install_path% %soci_download_path%
       
    cmake --build . --config Debug --target install
    

    Die Pfade musst du natürlich für dich korrekt setzen.



  • Vielen Dank 😁 👍🏻

    Ich teste es gleich morgen gebe Rückmeldung.



  • Also ich habs jetzt mal so gebuilded wie du geschrieben hast. Abgesehen von vereinzelten Warnungen bekomme ich beim linken den Fehler:

    libsoci_sqlite3_4_0.lib(statement.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "sqlite3_column_d
    ecltype" in Funktion ""public: virtual void __cdecl soci::sqlite3_statement_backend::describe_column(int,enum soci::dat
    a_type &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?describe_column@
    sqlite3_statement_backend@soci@@UEAAXHAEAW4data_type@2@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@
    @@Z)". [C:\CPP\Additional Includes\soci\build\tests\sqlite3\soci_sqlite3_test_static.vcxproj]
    C:\CPP\Additional Includes\soci\build\bin\Debug\soci_sqlite3_test_static.exe : fatal error LNK1120: 1 nicht aufgelöste
    Externe [C:\CPP\Additional Includes\soci\build\tests\sqlite3\soci_sqlite3_test_static.vcxproj]
    

    ich erhalte danach in /lib/Debug die libsoci_core_4_0.lib, libsoci_empty_4_0.lib und libsoci_sqlite3_4_0.lib.
    Mein CMakeScript sieht jetzt wie folgt aus:

    cmake_minimum_required(VERSION 3.17)
    
    project(SqliteTest)
    
    add_executable(SqliteTest)
    add_subdirectory(src)
    
    find_package(Soci)
    target_include_directories(SqliteTest PUBLIC "C:/CPP/Additional Includes/soci/include")
    target_include_directories(SqliteTest PUBLIC "C:/CPP/Additional Includes/SQLite3/include")
    list(APPEND LIBS ${SOCI_LIBRARY} ${SOCI_sqlite3_PLUGIN})
    target_link_libraries(SqliteTest PUBLIC ${LIBS})
    

    Dabei erhalte ich dann ebenfalls einen Fehler beim Linken:

    Microsoft (R)-Build-Engine, Version 16.5.0+d4cbfca49 für .NET Framework
    Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
    
      Checking Build System
      Building Custom Rule C:/CPP/Projects/SqliteTest/CMakeLists.txt
      main.cpp
    main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl soci::session::session(class soci::backend_factory const &,class std::basic_string<char,struct std::ch 
    ar_traits<char>,class std::allocator<char> > const &)" (??0session@soci@@QEAA@AEBVbackend_factory@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "main". [C 
    :\CPP\Projects\SqliteTest\build\SqliteTest.vcxproj]
    main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl soci::session::~session(void)" (??1session@soci@@QEAA@XZ)" in Funktion "main". [C:\CPP\Projects\Sqlite 
    Test\build\SqliteTest.vcxproj]
    main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __cdecl soci::session::close(void)" (?close@session@soci@@QEAAXXZ)" in Funktion "main". [C:\CPP\Projects\ 
    SqliteTest\build\SqliteTest.vcxproj]
    main.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""struct soci::sqlite3_backend_factory const soci::sqlite3" (?sqlite3@soci@@3Usqlite3_backend_factory@1@B)". [C:\CPP\Projects\Sqlite 
    Test\build\SqliteTest.vcxproj]
    C:\CPP\Projects\SqliteTest\build\Debug\SqliteTest.exe : fatal error LNK1120: 4 nicht aufgelöste Externe [C:\CPP\Projects\SqliteTest\build\SqliteTest.vcxproj]
    

Log in to reply