Skip to content

victorkryz/HRtoSQLite

Repository files navigation

$\color{teal}\textit{\textbf{HRtoSQLite}}$

C++ cmake poco OCI gtest Ubuntu Windows

HRtoSQLite utility transfers Oracle Database sample HR schema's data into SQLite database.

Motivations:

  • Get acquainted with the POCO C++.
  • Using POCO data access API for operating on SQLite database.
  • Make it cross-platform (Windows/Linux OS).

Features:

  • Oracle call interface (OCI) is used to Oracle database access;
  • Poco features:
    • there's used POCO-proposed skeleton for application organizing (Application class);
    • data access API (SQLite database);
    • command-line parameters handling feature;
    • logging into application log;
    • some utilities (e.g. string formatting);
  • "Google's C++ test" as a unit testing framework.
  • CMake based configuration;

Usage:


Command line arguments:

-h, --help                      display help information on command line arguments  
-C value, --ora-conn-str=value  Oracle connection string   (//host[:port]/service)  
-N value, --ora-name=value      Oracle user name (default: "hr")  
-P value, --ora-psw=value       Oracle user password  
-S file, --sqlt-ddl=file        HR-SQLite database structure initialization file  
                                (default: ./sql/hrSQLiteDDL.sql)  
-O file, --output=file          SQLite database file (default: ./hr.db)  

Connection string format conforms to Database Connection Strings for OCI Instant Client

Command line samples:

HRtoSQLite_run -C//oracle_host:1521/xe -N hr -P hr -S./../sql/hrSQLiteDDL.sql
HRtoSQLite_run -C//oracle_host1521/xepdb1 -N hr -P hr -S./../sql/hrSQLiteDDL.sql -O./../dbs/hr.db

Building:


(On the development phase, there's used POCO version 1.7.4, 1.13.3, 1.14.2, Oracle client 12.1, 21.11, 23.9, googletest-1.14.0)

  • For linux:

    The project building is based on CMake configuration files.
    Set the next variables that define headers and libraries directories:

    • go into file HRtoSQLite/CMakeLists.txt and set OCI and Poco paths in variables:
      OCI_INC_DIR, OCI_LIB_DIR, POCO_INC_DIR, POCO_LIB_DIR;
    • go into file HRtoSQLite_tests/g.tests/CMakeLists.txt and set google test paths in variables:
      GTEST_INC_DIR, GTEST_LIB_DIR

    To build it without IDE, using only CMake CLI, do steps like below:

      ```
      mkdir build-debug
      cd build-debug
      cmake -DCMAKE_BUILD_TYPE=Debug ../.
      cmake --build ./ --target all
      ```
    
  • For Windows (Visual Studio 2015):

    -go into directory HRtoSQLite.VS2015 and open HRToSQLiteWS.sln solution;

      Projects sesttings suppose the next default headers and libraries directories configuration:   
    
      ..\..\..\vendor\instantclient\sdk\include       - OCI headers
      ..\..\..\vendor\poco\include                    - POCO headers
      ..\..\..\vendor\instantclient\sdk\lib\msvc      - OCI libraries
      .\..\..\vendor\poco\lib64                       - POCO libraries
    

    (note: there's only x64 configuration provided)

    Simulate a similar directories disposition (e.g. using file system links) or substitute these directories on yours in projects settings ("Additional Include Directories", "Additional Library Directories")

Testing:


To get the unit tests runnable, build the sub-project HRtoSQLite_tests.
There are provided a set of tests for Oracle connection, reading 'HR' schema tables, writing data into SQLite database, e.g.

The tests are parametrized by environment variables:

ORA_CONN_STR   Oracle connection string
ORA_NAME       Oracle user name
ORA_PSW        Oracle user password 
SQLT_DDL       HR-SQLite database structure initialization file
OUTPUT         SQLite database file (default: ./hr.db)

Directory 'Launchers' contains some configuration and scripts to help test launching.
To launch unit tests from command line, setup variables in 'config.env' file and launch 'testLauncher' script.

Warning: in case these tests are launched under from IDE (e.g.Visual Studio), setup the given environment variables in the respective configuration (debug/run) before debugging or running some test(s)!


The project has been built and tested on the following platforms:

  • Ubuntu 18.04 LTS (64-bit) (g++ 11.4.0)
  • Ubuntu 24.04 LTS (64-bit) (g++ 13.3.0)
  • Red Hat 7.2 (64-bit) (g++ 4.8.5-11)
  • Windows 7 (64-bit) (Microsoft Visual Studio 2015 (Version 14.0.25123.00))

About

Exports Oracle Database sample HR schema into SQLite database.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published