#include <driver.h>
Classes | |
| class | Info |
Public Types | |
| enum | Features { NoFeatures = 0 , SingleTransactions = 1 , MultipleTransactions = 2 , NestedTransactions = 4 , CursorForward = 8 , CursorBackward = (CursorForward+16) , CompactingDatabaseSupported = 32 , IgnoreTransactions = 1024 } |
| enum | CreateConnectionOptions { ReadOnlyConnection = 1 } |
| enum | EscapeType { EscapeDriver = 0x01 , EscapeKexi = 0x02 } |
| enum | EscapePolicy { EscapeAsNecessary = 0x04 , EscapeAlways = 0x08 } |
| typedef TQMap< TQString, Info > | InfoMap |
Public Member Functions | |
| Connection * | createConnection (ConnectionData &conn_data, int options=0) |
| const TQPtrList< Connection > | connectionsList () const |
| TQString | fileDBDriverMimeType () const |
| const KService * | service () const |
| bool | isFileDriver () const |
| virtual bool | isSystemObjectName (const TQString &n) const |
| virtual bool | isSystemDatabaseName (const TQString &n) const =0 |
| bool | isSystemFieldName (const TQString &n) const |
| int | features () const |
| bool | transactionsSupported () const |
| AdminTools & | adminTools () const |
| virtual TQString | sqlTypeName (int id_t, int p=0) const |
| virtual bool | isValid () |
| virtual DatabaseVersionInfo | version () const =0 |
| virtual TQString | valueToSQL (uint ftype, const TQVariant &v) const |
| TQString | valueToSQL (const TQString &ftype, const TQVariant &v) const |
| TQString | valueToSQL (const Field *field, const TQVariant &v) const |
| virtual TQString | dateTimeToSQL (const TQDateTime &v) const |
| virtual TQString | escapeString (const TQString &str) const =0 |
| virtual TQCString | escapeString (const TQCString &str) const =0 |
| virtual TQString | escapeBLOB (const TQByteArray &array) const =0 |
| TQString | escapeIdentifier (const TQString &str, int options=EscapeDriver|EscapeAsNecessary) const |
| TQCString | escapeIdentifier (const TQCString &str, int options=EscapeDriver|EscapeAsNecessary) const |
| TQVariant | propertyValue (const TQCString &propName) const |
| TQString | propertyCaption (const TQCString &propName) const |
| TQValueList< TQCString > | propertyNames () const |
| Public Member Functions inherited from KexiDB::Object | |
| bool | error () const |
| const TQString & | errorMsg () const |
| int | errorNum () const |
| int | previousServerResult () const |
| TQString | previousServerResultName () const |
| void | debugError () |
| virtual void | clearError () |
| virtual TQString | serverErrorMsg () |
| virtual int | serverResult () |
| virtual TQString | serverResultName () |
| TQString | msgTitle () const |
| const TQString | recentSQLString () const |
Static Public Member Functions | |
| static TQString | defaultFileBasedDriverMimeType () |
| static TQString | defaultFileBasedDriverName () |
| static bool | isKexiDBSystemObjectName (const TQString &n) |
| static TQString | defaultSQLTypeName (int id_t) |
Protected Member Functions | |
| Driver (TQObject *parent, const char *name, const TQStringList &args=TQStringList()) | |
| virtual Connection * | drv_createConnection (ConnectionData &conn_data)=0 |
| virtual TQString | drv_escapeIdentifier (const TQString &str) const =0 |
| virtual TQCString | drv_escapeIdentifier (const TQCString &str) const =0 |
| virtual bool | drv_isSystemFieldName (const TQString &n) const =0 |
| virtual AdminTools * | drv_createAdminTools () const |
| Connection * | removeConnection (Connection *conn) |
| void | initSQLKeywords (int hashSize=17) |
| Protected Member Functions inherited from KexiDB::Object | |
| Object (MessageHandler *handler=0) | |
| virtual void | setError (int code=ERR_OTHER, const TQString &msg=TQString()) |
| virtual void | setError (const TQString &msg) |
| virtual void | setError (const TQString &title, const TQString &msg) |
| void | setError (KexiDB::Object *obj, const TQString &prependMessage=TQString()) |
| virtual void | setError (KexiDB::Object *obj, int code, const TQString &prependMessage=TQString()) |
| virtual int | askQuestion (const TQString &message, KMessageBox::DialogType dlgType, KMessageBox::ButtonCode defaultResult, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontShowAskAgainName=TQString(), int options=KMessageBox::Notify, MessageHandler *msgHandler=0) |
| virtual void | drv_clearServerResult () |
Protected Attributes | |
| DriverBehaviour * | beh |
| DriverPrivate * | d |
| Protected Attributes inherited from KexiDB::Object | |
| TQString | m_sql |
| TQString | m_errorSql |
| int | m_serverResult |
| TQString | m_serverResultName |
| TQString | m_serverErrorMsg |
| TQString | m_errMsg |
Friends | |
| class | Connection |
| class | Cursor |
| class | DriverManagerInternal |
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 TDETrader 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
Member Typedef Documentation
◆ InfoMap
Member Enumeration Documentation
◆ CreateConnectionOptions
Options used for createConnection().
| Enumerator | |
|---|---|
| ReadOnlyConnection | set to perform read only connection |
◆ EscapePolicy
◆ EscapeType
◆ Features
Features supported by driver (sum of few Features enum items).
| Enumerator | |
|---|---|
| SingleTransactions | single trasactions are only supported |
| MultipleTransactions | multiple concurrent trasactions are supported (this implies !SingleTransactions) |
| NestedTransactions | nested trasactions are supported (this should imply !SingleTransactions and MultipleTransactions) |
| CursorForward | forward moving is supported for cursors (if not available, no cursors available at all) |
| CursorBackward | backward moving is supported for cursors (this implies CursorForward) |
| CompactingDatabaseSupported | compacting database supported (aka VACUUM) |
| IgnoreTransactions | If set, actions related to transactions will be silently bypassed with success. Set this if your driver does not support transactions at all Currently, this is only way to get it working with KexiDB. Keep in mind that this hack do not provide data integrity! This flag is currently used for MySQL driver. |
Constructor & Destructor Documentation
◆ Driver()
|
protected |
Used by DriverManager. Note for driver developers: Reimplement this. In your reimplementation you should initialize:
- d->typeNames - to types accepted by your engine
- d->isFileDriver - to true or false depending if your driver is file-based
- d->features - to combination of selected values from Features enum
You may also want to change options in DriverBehaviour *beh member. See drivers/mySQL/mysqldriver.cpp for usage example.
Member Function Documentation
◆ adminTools()
| AdminTools & Driver::adminTools | ( | ) | const |
- Returns
- admin tools object providing a number of database administration tools for the driver. Tools availablility varies from driver to driver. You can check it using features().
Definition at line 158 of file driver.cpp.
◆ connectionsList()
| const TQPtrList< Connection > Driver::connectionsList | ( | ) | const |
- Returns
- List of created connections.
Definition at line 125 of file driver.cpp.
◆ createConnection()
| Connection * Driver::createConnection | ( | ConnectionData & | conn_data, |
| int | options = 0 ) |
Creates connection using conn_data as parameters.
- Returns
- 0 and sets error message on error. driverName member of conn_data will be updated with this driver name. options can be a combination of CreateConnectionOptions enum values.
Definition at line 178 of file driver.cpp.
◆ dateTimeToSQL()
|
inlinevirtual |
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")
- Todo
- add support for time zones?
◆ defaultFileBasedDriverMimeType()
|
static |
- Returns
- default file-based driver mime type (typically something like "application/x-kexiproject-sqlite")
Definition at line 137 of file driver.cpp.
◆ defaultFileBasedDriverName()
|
static |
- Returns
- default file-based driver name (currently, "sqlite3").
Definition at line 140 of file driver.cpp.
◆ defaultSQLTypeName()
|
static |
used when we do not have Driver instance yet
Definition at line 206 of file driver.cpp.
◆ drv_createAdminTools()
|
protectedvirtual |
Definition at line 165 of file driver.cpp.
◆ drv_createConnection()
|
protectedpure virtual |
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.
◆ drv_escapeIdentifier() [1/2]
|
protectedpure virtual |
This is overloaded version of drv_escapeIdentifier( const TQString& str ) to be implemented in the same way.
Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver.
◆ drv_escapeIdentifier() [2/2]
|
protectedpure virtual |
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.
◆ drv_isSystemFieldName()
|
protectedpure virtual |
- Returns
- true if n is a system field's name, build-in system field that cannot be used or created by a user, and in most cases user even shouldn't see this. The list is specific for a given driver implementation. For implementation.
Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver.
◆ escapeBLOB()
|
pure virtual |
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.
◆ escapeIdentifier() [1/2]
| TQCString Driver::escapeIdentifier | ( | const TQCString & | str, |
| int | options = EscapeDriver|EscapeAsNecessary ) const |
Definition at line 322 of file driver.cpp.
◆ escapeIdentifier() [2/2]
| TQString Driver::escapeIdentifier | ( | const TQString & | str, |
| int | options = EscapeDriver|EscapeAsNecessary ) const |
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 316 of file driver.cpp.
◆ escapeString() [1/2]
|
pure virtual |
This is overloaded version of escapeString( const TQString& str ) to be implemented in the same way.
Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver.
◆ escapeString() [2/2]
|
pure virtual |
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.
◆ features()
| int Driver::features | ( | ) | const |
- Returns
- Driver's features that are combination of Driver::Features enum.
Definition at line 152 of file driver.cpp.
◆ fileDBDriverMimeType()
| TQString Driver::fileDBDriverMimeType | ( | ) | const |
- Returns
- a name equal to the service name (X-Kexi-DriverName) stored in given service .desktop file.
- a name of MIME type of files handled by this driver if it is a file-based database's driver (equal X-Kexi-FileDBDriverMime service property) otherwise returns null string.
- See also
- isFileDriver()
Definition at line 134 of file driver.cpp.
◆ initSQLKeywords()
|
protected |
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.
- See also
- DriverPrivate::SQL_KEYWORDS.
Definition at line 360 of file driver.cpp.
◆ isFileDriver()
| bool Driver::isFileDriver | ( | ) | const |
- Returns
- true if this driver is file-based
Definition at line 149 of file driver.cpp.
◆ isKexiDBSystemObjectName()
|
static |
- Returns
- true if n is a kexibd-related 'system' object's name, i.e. when n starts with "kexi__" prefix.
Definition at line 235 of file driver.cpp.
◆ isSystemDatabaseName()
|
pure virtual |
- Returns
- true if n is a system database's name, eg. name of build-in, system database that cannot be used or created by a user, and in most cases user even shouldn't see this. The list is specific for a given driver implementation. For implementation.
- See also
- isSystemObjectName().
Implemented in KexiDB::MySqlDriver, KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver.
◆ isSystemFieldName()
| bool Driver::isSystemFieldName | ( | const TQString & | n | ) | const |
- Returns
- true if n is a system field's name, build-in system field that cannot be used or created by a user, and in most cases user even shouldn't see this. The list is specific for a given driver implementation.
- See also
- isSystemObjectName().
Definition at line 243 of file driver.cpp.
◆ isSystemObjectName()
|
virtual |
- Returns
- true if n is a system object's name, eg. name of build-in system table that cannot be used or created by a user, and in most cases user even shouldn't see this. The list is specific for a given driver implementation. By default calls Driver::isKexiDBSystemObjectName() static method. Note for driver developers: Also call Driver::isSystemObjectName() from your reimplementation.
- See also
- isSystemFieldName().
Reimplemented in KexiDB::pqxxSqlDriver, and KexiDB::SQLiteDriver.
Definition at line 230 of file driver.cpp.
◆ isValid()
|
virtual |
- Returns
- true if this driver's implementation is valid. Just few constriants are checked to ensure that driver developer didn't forget about something. This method is called automatically on createConnection(), and proper error message is set properly on any error.
◆ propertyCaption()
| TQString Driver::propertyCaption | ( | const TQCString & | propName | ) | const |
- Returns
- translated property caption for propeName. If there's no such property defined for driver, empty string value is returned.
Definition at line 304 of file driver.cpp.
◆ propertyNames()
| TQValueList< TQCString > Driver::propertyNames | ( | ) | const |
- Returns
- a list of property names available for this driver.
Definition at line 309 of file driver.cpp.
◆ propertyValue()
| TQVariant Driver::propertyValue | ( | const TQCString & | propName | ) | const |
- Returns
- property value for propeName available for this driver. If there's no such property defined for driver, Null TQVariant value is returned.
Definition at line 299 of file driver.cpp.
◆ removeConnection()
|
protected |
- Returns
- connection conn , do not deletes it nor affect. Returns 0 if conn is not owned by this driver. After this, you are owner of conn object, so you should eventually delete it. Better use Connection destructor.
Definition at line 200 of file driver.cpp.
◆ service()
| const KService * Driver::service | ( | ) | const |
Info about the driver as a service.
Definition at line 146 of file driver.cpp.
◆ sqlTypeName()
|
virtual |
SQL-implementation-dependent name of given type
Reimplemented in KexiDB::pqxxSqlDriver.
Definition at line 170 of file driver.cpp.
◆ transactionsSupported()
| bool Driver::transactionsSupported | ( | ) | const |
- Returns
- true if transaction are supported (single or multiple).
Definition at line 155 of file driver.cpp.
◆ valueToSQL() [1/3]
|
inline |
◆ valueToSQL() [2/3]
|
inline |
◆ valueToSQL() [3/3]
|
virtual |
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.
- See also
- TQt::DateFormat
Reimplemented in KexiDB::pqxxSqlDriver.
Definition at line 250 of file driver.cpp.
◆ version()
|
pure virtual |
Friends And Related Symbol Documentation
◆ Connection
◆ Cursor
◆ DriverManagerInternal
Member Data Documentation
◆ beh
◆ d
The documentation for this class was generated from the following files:
