sptk2 logo
SPTK Home Page
Classes | Typedefs | Enumerations | Functions
Database Support

Classes

class  sptk::AutoDatabaseConnection
 
class  sptk::DatabaseConnectionParameters
 Database connection parameters. More...
 
struct  sptk::DatabaseDriver
 
class  sptk::DatabaseConnectionPool
 
class  sptk::DatabaseConnectionString
 
class  sptk::DatabaseField
 database field More...
 
class  sptk::InsertQuery
 
struct  sptk::QueryColumnTypeSize
 
class  sptk::PoolDatabaseConnectionQueryMethods
 
class  sptk::PoolDatabaseConnection
 
class  sptk::QueryStatementManagement
 
class  sptk::Query
 
class  sptk::QueryParameterBinding
 
class  sptk::QueryParameterList
 
class  sptk::Transaction
 Database Transaction. More...
 

Typedefs

using sptk::DatabaseConnection = std::shared_ptr< AutoDatabaseConnection >
 
using sptk::CreateDriverInstance = PoolDatabaseConnection *(const char *connectString, size_t connectTimeoutSeconds)
 
using sptk::DestroyDriverInstance = void(PoolDatabaseConnection *)
 
using sptk::DriverHandle = uint8_t *
 
using sptk::SDatabaseConnectionString = std::shared_ptr< DatabaseConnectionString >
 
using sptk::SDatabaseField = std::shared_ptr< DatabaseField >
 
using sptk::DBHandle = uint8_t *
 
using sptk::StmtHandle = uint8_t *
 
using sptk::SStmtHandle = std::shared_ptr< uint8_t >
 
using sptk::QueryColumnTypeSizeVector = std::vector< QueryColumnTypeSize >
 
using sptk::QueryColumnTypeSizeMap = std::map< std::string, QueryColumnTypeSize, std::less<> >
 
using sptk::SPoolDatabaseConnection = std::shared_ptr< PoolDatabaseConnection >
 
using sptk::SQuery = std::shared_ptr< Query >
 
using sptk::CParamVector = std::vector< SQueryParameter >
 

Enumerations

enum class  sptk::DatabaseConnectionType : uint16_t {
  DatabaseConnectionType::UNKNOWN = 0 , DatabaseConnectionType::MYSQL = 1 , DatabaseConnectionType::ORACLE = 2 , DatabaseConnectionType::POSTGRES = 4 ,
  DatabaseConnectionType::SQLITE3 = 8 , DatabaseConnectionType::FIREBIRD = 16 , DatabaseConnectionType::GENERIC_ODBC = 32 , DatabaseConnectionType::MSSQL_ODBC = 64
}
 
enum class  sptk::DatabaseObjectType : uint8_t {
  DatabaseObjectType::UNDEFINED , DatabaseObjectType::TABLES , DatabaseObjectType::VIEWS , DatabaseObjectType::PROCEDURES ,
  DatabaseObjectType::FUNCTIONS , DatabaseObjectType::DATABASES
}
 

Functions

 sptk::InsertQuery::InsertQuery (const DatabaseConnection &db, const String &sql="", const String &idFieldName="id")
 
String sptk::InsertQuery::sql () const override
 
void sptk::InsertQuery::sql (const String &_sql) override
 
void sptk::InsertQuery::exec () override
 
void sptk::InsertQuery::exec (const String &newSQL) override
 
uint64_t sptk::InsertQuery::id () const
 
SP_EXPORT String sptk::escapeSQLString (const String &str, bool tsv=false)
 

Detailed Description

SPTK_OracleConnection

Typedef Documentation

◆ CParamVector

using sptk::CParamVector = typedef std::vector<SQueryParameter>

A vector of CParam*

Doesn't mantain CParam memory. Used to return a list of pointers on existing parameters.

◆ CreateDriverInstance

using sptk::CreateDriverInstance = typedef PoolDatabaseConnection*(const char* connectString, size_t connectTimeoutSeconds)

Create driver instance function type

◆ DestroyDriverInstance

Destroy driver instance function type

◆ DriverHandle

using sptk::DriverHandle = typedef uint8_t*

Unix: Driver shared library handle type

◆ QueryColumnTypeSizeMap

using sptk::QueryColumnTypeSizeMap = typedef std::map<std::string, QueryColumnTypeSize, std::less<> >

Map of column names to column type and size structures

◆ QueryColumnTypeSizeVector

Vector of column type and size structures

Enumeration Type Documentation

◆ DatabaseConnectionType

enum class sptk::DatabaseConnectionType : uint16_t
strong

Database connection type

Enumerator
UNKNOWN 

Unknown.

MYSQL 

MySQL.

ORACLE 

Oracle.

POSTGRES 

PostgreSQL.

SQLITE3 

SQLite3.

FIREBIRD 

Firebird.

GENERIC_ODBC 

Generic ODBC.

MSSQL_ODBC 

MS SQL ODBC.

◆ DatabaseObjectType

enum class sptk::DatabaseObjectType : uint8_t
strong

Types of the objects for DatabaseConnection::listObjects method

Enumerator
UNDEFINED 

Undefined.

TABLES 

Tables.

VIEWS 

Views.

PROCEDURES 

Stored procedures.

FUNCTIONS 

Stored functions.

DATABASES 

Available databases.

Function Documentation

◆ escapeSQLString()

SP_EXPORT String sptk::escapeSQLString ( const String str,
bool  tsv = false 
)

Escape SQL string for bulk insert

Parameters
strString to escape
tsvTrue if output data is TSV (tab-separated values)
Returns
Escaped string

◆ exec() [1/2]

void sptk::InsertQuery::exec ( )
overridevirtual

Executes insert query.

Retrieves value of "id" field and sets internal value for id().

Reimplemented from sptk::Query.

◆ exec() [2/2]

void sptk::InsertQuery::exec ( const String newSQL)
inlineoverridevirtual

Executes the query and closes the statement.

Query SQL would be set to the new SQL statement

Parameters
newSQLSQL statement to execute

Reimplemented from sptk::Query.

◆ id()

uint64_t sptk::InsertQuery::id ( ) const
inline

Get created record id

Returns
created record id

◆ InsertQuery()

sptk::InsertQuery::InsertQuery ( const DatabaseConnection &  db,
const String sql = "",
const String idFieldName = "id" 
)
explicit

Constructor

You can optionally provide the name of the file and line number where this query is created. This is used to collect statistical information for the query calls. If file and line information is provided, then calls statistics is stored to the database object during the query dtor.

Parameters
dbDatabase connection
sqlSQL query, optional
idFieldNameName of auto-incremental field

◆ sql() [1/2]

String sptk::InsertQuery::sql ( ) const
overridevirtual

Return query' SQL

Returns
SQL

Reimplemented from sptk::Query.

◆ sql() [2/2]

void sptk::InsertQuery::sql ( const String _sql)
overridevirtual

Sets SQL Query text. If the Query text is not the same and the db statement was prepared earlier then the db statement is released and new one is created.

Parameters
_sqlQuery SQL

Reimplemented from sptk::Query.


Fri Oct 14 2022 09:58:32: SPTK 5.4.1