kexi
KexiDB::Driver Class Reference
#include <driver.h>
Inheritance diagram for KexiDB::Driver:

Detailed Description
Generic database abstraction.This class is a prototype of the database driver for implementations. Driver allows new connections to be created, and groups these as a parent. Before destruction, all connections are destructed.
Notes:
- driver must be provided within KDE module file named with "kexidb_" prefix
- following line should be placed in driver's implementation: where:
KEXIDB_DRIVER_INFO( CLASS_NAME, INTERNAL_NAME );
- CLASS_NAME is actual driver's class name, e.g. MySqlDriver
- INTERNAL_NAME is driver name's most significant part (without quotation marks), e.g. mysql Above information uses K_EXPORT_COMPONENT_FACTORY macro for KTrader to find the module's entry point. For example, this line declares kexidb_mysqldriver.so module's entry point:
KEXIDB_DRIVER_INFO( MySqlDriver, mysql );
- See also:
- SQLiteDriver MySqlDriver, pqxxSqlDriver
Definition at line 64 of file driver.h.
Public Types | |
typedef QMap< QString, Info > | InfoMap |
enum | Features { NoFeatures = 0, SingleTransactions = 1, MultipleTransactions = 2, NestedTransactions = 4, CursorForward = 8, CursorBackward = (CursorForward+16), IgnoreTransactions = 1024 } |
enum | CreateConnectionOptions { ReadOnlyConnection = 1 } |
enum | EscapeType { EscapeDriver = 0x01, EscapeKexi = 0x02 } |
enum | EscapePolicy { EscapeAsNecessary = 0x04, EscapeAlways = 0x08 } |
Public Member Functions | |
virtual | ~Driver () |
Connection * | createConnection (ConnectionData &conn_data, int options=0) |
const QPtrList< Connection > | connectionsList () const |
QString | fileDBDriverMimeType () const |
const KService * | service () const |
bool | isFileDriver () const |
virtual bool | isSystemObjectName (const QString &n) const |
virtual bool | isSystemDatabaseName (const QString &n) const =0 |
bool | isSystemFieldName (const QString &n) const |
int | features () const |
bool | transactionsSupported () const |
virtual QString | sqlTypeName (int id_t, int p=0) const |
virtual bool | isValid () |
virtual int | versionMajor () const =0 |
virtual int | versionMinor () const =0 |
virtual QString | valueToSQL (uint ftype, const QVariant &v) const |
QString | valueToSQL (const QString &ftype, const QVariant &v) const |
QString | valueToSQL (const Field *field, const QVariant &v) const |
virtual QString | dateTimeToSQL (const QDateTime &v) const |
virtual QString | escapeString (const QString &str) const =0 |
virtual QCString | escapeString (const QCString &str) const =0 |
virtual QString | escapeBLOB (const QByteArray &array) const =0 |
QString | escapeIdentifier (const QString &str, int options=EscapeDriver|EscapeAsNecessary) const |
QCString | escapeIdentifier (const QCString &str, int options=EscapeDriver|EscapeAsNecessary) const |
QVariant | propertyValue (const QCString &propName) const |
QString | propertyCaption (const QCString &propName) const |
QValueList< QCString > | propertyNames () const |
Static Public Member Functions | |
static QString | defaultFileBasedDriverMimeType () |
static QString | defaultFileBasedDriverName () |
static bool | isKexiDBSystemObjectName (const QString &n) |
static QString | defaultSQLTypeName (int id_t) |
Protected Member Functions | |
Driver (QObject *parent, const char *name, const QStringList &args=QStringList()) | |
virtual Connection * | drv_createConnection (ConnectionData &conn_data)=0 |
virtual QString | drv_escapeIdentifier (const QString &str) const =0 |
virtual QCString | drv_escapeIdentifier (const QCString &str) const =0 |
virtual bool | drv_isSystemFieldName (const QString &n) const =0 |
Connection * | removeConnection (Connection *conn) |
QString | escapeBLOBInternal (const QByteArray &array, int type) const |
void | initSQLKeywords (int hashSize=17) |
Protected Attributes | |
DriverBehaviour * | beh |
DriverPrivate * | d |
Friends | |
class | Connection |
class | Cursor |
class | DriverManagerInternal |
Classes | |
class | Info |
Member Enumeration Documentation
|
Options used for createConnection().
|
|
Features supported by driver (sum of few Features enum items).
|
Constructor & Destructor Documentation
|
Used by DriverManager. Note for driver developers: Reimplement this. In your reimplementation you should initialize:
You may also want to change options in DriverBehaviour *beh member. See drivers/mySQL/mysqldriver.cpp for usage example. Definition at line 64 of file driver.cpp. |
Member Function Documentation
|
Definition at line 117 of file driver.cpp. |
|
Creates connection using conn_data as parameters.
Definition at line 158 of file driver.cpp. |
|
not compatible with all drivers - reimplement (was compatible with SQLite: http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions) Now it's ISO 8601 DateTime format - with "T" delimiter: http://www.w3.org/TR/NOTE-datetime (e.g. "1994-11-05T13:15:30" not "1994-11-05 13:15:30")
|
|
Definition at line 129 of file driver.cpp. |
|
Definition at line 132 of file driver.cpp. |
|
used when we do not have Driver instance yet Definition at line 186 of file driver.cpp. |
|
For reimplemenation: creates and returns connection object with additional structures specific for a given driver. Connection object should inherit Connection and have a destructor that descructs all allocated driver-dependent connection structures. Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
This is overloaded version of drv_escapeIdentifier( const QString& str ) to be implemented in the same way. Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Driver-specific SQL string escaping. This method is used by escapeIdentifier(). Implement escaping for any character like " or ' as your database engine requires. Do not append or prepend any quotation marks characters - it is automatically done by escapeIdentifier() using DriverBehaviour::QUOTATION_MARKS_FOR_IDENTIFIER. Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Driver-specific SQL BLOB value escaping. Implement escaping for any character like " or ' and \0 as your database engine requires. Prepend and append quotation marks. Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Helper, used in escapeBLOB(). use type == BLOB_ESCAPING_TYPE_USE_X to get escaping like X'ABCD0' (used by sqlite) use type == BLOB_ESCAPING_TYPE_USE_0x to get escaping like 0xABCD0 (used by mysql) use type == BLOB_ESCAPING_TYPE_USE_OCTAL to get escaping like '\253\315\000' (used by pgsql) Definition at line 341 of file driver.cpp. |
|
Driver-specific identifier escaping (e.g. for a table name, db name, etc.). Escape database identifier (str) in order that keywords can be used as table names, column names, etc. options is the union of the EscapeType and EscapePolicy types. If no escaping options are given, defaults to driver escaping as necessary. Definition at line 286 of file driver.cpp. |
|
This is overloaded version of escapeString( const QString& str ) to be implemented in the same way. Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Driver-specific SQL string escaping. Implement escaping for any character like " or ' as your database engine requires. Prepend and append quotation marks. Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Definition at line 144 of file driver.cpp. |
|
Definition at line 126 of file driver.cpp. |
|
Used to initialise the dictionary of driver-specific keywords. Should be called by the Driver's constructor. hashSize is the number of buckets to use in the dictionary.
Definition at line 330 of file driver.cpp. |
|
Definition at line 141 of file driver.cpp. |
|
Definition at line 214 of file driver.cpp. |
|
Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. |
|
Definition at line 222 of file driver.cpp. |
|
Reimplemented in KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver. Definition at line 209 of file driver.cpp. |
|
Definition at line 93 of file driver.cpp. |
|
Definition at line 274 of file driver.cpp. |
|
Definition at line 279 of file driver.cpp. |
|
Definition at line 269 of file driver.cpp. |
|
Definition at line 180 of file driver.cpp. |
|
Info about the driver as a service. Definition at line 138 of file driver.cpp. |
|
SQL-implementation-dependent name of given type Reimplemented in KexiDB::pqxxSqlDriver. Definition at line 150 of file driver.cpp. |
|
Definition at line 147 of file driver.cpp. |
|
Like above method, for field.
|
|
Like above but with the fildtype as string.
|
|
Escapes and converts value v (for type ftype) to string representation required by SQL commands. Reimplement this if you need other behaviour (eg. for 'date' type handling) This implementation return date, datetime and time values in ISO format, what seems to be accepted by SQL servers.
Definition at line 229 of file driver.cpp. |
|
Driver's static version information, it is automatically defined in implementation using KEXIDB_DRIVER macro (see driver_p.h) |
Member Data Documentation
|
for future extensions
Reimplemented from KexiDB::Object. |
The documentation for this class was generated from the following files: