This page is dedicated to database-related programs, that can help in SPTK-based development. At the moment, only one utility is included here. The Perl script Sql2Cpp.pl (included with SPTK distribution) allows generation of C++ interface classes for PostgreSQL stored procedures. Why is it needed? For a large database-related project that uses many stored procedures, it is important to have the universal way to call these procedures.
How does it work? Sql2Cpp reads SQL-scripts that create stored procedures, and generates C++ source files. Every C++ source file defines a single class (that corresponds to SQL-script file). Every method implements a single stored procedure call. Sql2Cpp tries to support a strong type control of parameters and returned data. That is achieved by using classes for DB-specific types such as table and view records. What databases are supported? Currently, it is only PostgreSQL. We are planning to add more server types in the future. How the class names/input paths/etc are configured? Sql2Cpp comes with the default configuration file that allows to define many useful generation parameters. Please, let us know if you need to tweak something else. How can I try it? Sql2Cpp is included with the SPTK starting from version 3.5.7.08. All the files needed for testing are located in dbtools/ sub-directory. In order to try Sql2Cpp, you have to setup PostgreSQL server with default database for your user. After that, run the command: perl sql2cpp.pl The test would create two C++ modules, CAuthor{.h,.cpp} and CBook{.h,.cpp} in src/ sub-directory. You can now change the configuration parameters, or edit stored procedure files, and run Sql2Cpp again.
|