Kexi API Documentation (2.0 alpha)

KexiDB::Connection Class Reference

#include <connection.h>

Inheritance diagram for KexiDB::Connection:

KexiDB::Object KexiDB::MySqlConnection KexiDB::pqxxSqlConnection KexiDB::SQLiteConnection List of all members.

Detailed Description

Provides database connection, allowing queries and data modification.

This class represents a database connection established within a data source. It supports data queries and modification by creating client-side database cursors. Database transactions are supported.

Definition at line 61 of file connection.h.

Public Member Functions

virtual ~Connection ()
ConnectionDatadata () const
Driverdriver () const
bool connect ()
 Connects to driver with given parameters.
bool isConnected () const
bool isDatabaseUsed () const
virtual bool isReadOnly () const
virtual void clearError ()
bool disconnect ()
 Disconnects from driver with given parameters.
QStringList databaseNames (bool also_system_db=false)
bool databaseExists (const QString &dbName, bool ignoreErrors=true)
bool createDatabase (const QString &dbName)
 Creates new database with name dbName, using this connection.
bool useDatabase (const QString &dbName, bool kexiCompatible=true, bool *cancelled=0, MessageHandler *msgHandler=0)
 Opens an existing database specified by dbName.
bool closeDatabase ()
 Closes currently used database for this connection.
QString currentDatabase () const
 Get the name of the current database.
bool dropDatabase (const QString &dbName=QString::null)
 Drops database with name dbName.
QStringList objectNames (int objType=KexiDB::AnyObjectType, bool *ok=0)
QStringList tableNames (bool also_system_tables=false)
KexiDB::ServerVersionInfoserverVersion () const
KexiDB::DatabaseVersionInfodatabaseVersion () const
DatabasePropertiesdatabaseProperties ()
QValueList< int > tableIds ()
QValueList< int > queryIds ()
QValueList< int > objectIds (int objType)
Transaction beginTransaction ()
 Creates new transaction handle and starts a new transaction.
bool commitTransaction (Transaction trans=Transaction::null, bool ignore_inactive=false)
bool rollbackTransaction (Transaction trans=Transaction::null, bool ignore_inactive=false)
TransactiondefaultTransaction () const
void setDefaultTransaction (const Transaction &trans)
const QValueList< Transaction > & transactions ()
bool autoCommit () const
bool setAutoCommit (bool on)
virtual CursorprepareQuery (const QString &statement, uint cursor_options=0)=0
CursorprepareQuery (QuerySchema &query, const QValueList< QVariant > &params, uint cursor_options=0)
virtual CursorprepareQuery (QuerySchema &query, uint cursor_options=0)=0
CursorprepareQuery (TableSchema &table, uint cursor_options=0)
CursorexecuteQuery (const QString &statement, uint cursor_options=0)
CursorexecuteQuery (QuerySchema &query, const QValueList< QVariant > &params, uint cursor_options=0)
CursorexecuteQuery (QuerySchema &query, uint cursor_options=0)
CursorexecuteQuery (TableSchema &table, uint cursor_options=0)
bool deleteCursor (Cursor *cursor)
TableSchematableSchema (int tableId)
TableSchematableSchema (const QString &tableName)
QuerySchemaquerySchema (int queryId)
QuerySchemaquerySchema (const QString &queryName)
bool setQuerySchemaObsolete (const QString &queryName)
tristate querySingleRecord (const QString &sql, RowData &data, bool addLimitTo1=true)
tristate querySingleRecord (QuerySchema &query, RowData &data, bool addLimitTo1=true)
tristate querySingleString (const QString &sql, QString &value, uint column=0, bool addLimitTo1=true)
tristate querySingleNumber (const QString &sql, int &number, uint column=0, bool addLimitTo1=true)
bool queryStringList (const QString &sql, QStringList &list, uint column=0)
bool resultExists (const QString &sql, bool &success, bool addLimitTo1=true)
bool isEmpty (TableSchema &table, bool &success)
int resultCount (const QString &sql)
bool insertRecord (TableSchema &tableSchema, QValueList< QVariant > &values)
bool insertRecord (FieldList &fields, QValueList< QVariant > &values)
bool createTable (TableSchema *tableSchema, bool replaceExisting=false)
 Creates a table according to the given schema.
tristate dropTable (TableSchema *tableSchema)
 Drops a table corresponding to the name in the given schema.
tristate dropTable (const QString &table)
tristate alterTable (TableSchema &tableSchema, TableSchema &newTableSchema)
bool alterTableName (TableSchema &tableSchema, const QString &newName, bool replace=false)
bool dropQuery (QuerySchema *querySchema)
bool dropQuery (const QString &query)
bool removeObject (uint objId)
FieldfindSystemFieldName (FieldList *fieldlist)
virtual QString anyAvailableDatabaseName ()
void setAvailableDatabaseName (const QString &dbName)
bool useTemporaryDatabaseIfNeeded (QString &tmpdbName)
Q_ULLONG lastInsertedAutoIncValue (const QString &aiFieldName, const QString &tableName, Q_ULLONG *ROWID=0)
Q_ULLONG lastInsertedAutoIncValue (const QString &aiFieldName, const TableSchema &table, Q_ULLONG *ROWID=0)
bool executeSQL (const QString &statement)
QString selectStatement (QuerySchema &querySchema, const QValueList< QVariant > &params, const SelectStatementOptions &options=SelectStatementOptions()) const
QString selectStatement (QuerySchema &querySchema, const SelectStatementOptions &options=SelectStatementOptions()) const
bool storeObjectSchemaData (SchemaData &sdata, bool newObject)
tristate loadObjectSchemaData (int objectID, SchemaData &sdata)
tristate loadObjectSchemaData (int objectType, const QString &objectName, SchemaData &sdata)
tristate loadDataBlock (int objectID, QString &dataString, const QString &dataID)
bool storeDataBlock (int objectID, const QString &dataString, const QString &dataID=QString::null)
bool removeDataBlock (int objectID, const QString &dataID=QString::null)
void registerForTableSchemaChanges (TableSchemaChangeListenerInterface &listener, TableSchema &schema)
 Register listener for receiving (listening) information about changes in TableSchema object.
void unregisterForTableSchemaChanges (TableSchemaChangeListenerInterface &listener, TableSchema &schema)
void unregisterForTablesSchemaChanges (TableSchemaChangeListenerInterface &listener)
QPtrList< Connection::TableSchemaChangeListenerInterface > * tableSchemaChangeListeners (TableSchema &tableSchema) const
tristate closeAllTableSchemaChangeListeners (TableSchema &tableSchema)
void removeTableSchemaInternal (KexiDB::TableSchema *tableSchema)
void insertInternalTableSchema (TableSchema *tableSchema)
virtual bool drv_containsTable (const QString &tableName)=0
virtual bool drv_createTable (const TableSchema &tableSchema)
virtual bool drv_alterTableName (TableSchema &tableSchema, const QString &newName)
virtual bool drv_dropTable (const QString &name)
virtual PreparedStatement::Ptr prepareStatement (PreparedStatement::StatementType type, FieldList &fields)=0
bool isInternalTableSchema (const QString &tableName)
bool setupObjectSchemaData (const RowData &data, SchemaData &sdata)
KexiDB::FieldsetupField (const RowData &data)

Static Public Member Functions

static const QStringList & kexiDBSystemTableNames ()

Public Attributes

 H_INS_REC_ALL

Protected Member Functions

 Connection (Driver *driver, ConnectionData &conn_data)
void destroy ()
tristate dropTable (KexiDB::TableSchema *tableSchema, bool alsoRemoveSchema)
virtual bool drv_connect (KexiDB::ServerVersionInfo &version)=0
virtual bool drv_disconnect ()=0
virtual bool drv_executeSQL (const QString &statement)=0
virtual bool drv_getDatabasesList (QStringList &list)
virtual bool drv_getTablesList (QStringList &list)=0
virtual bool drv_databaseExists (const QString &dbName, bool ignoreErrors=true)
virtual bool drv_createDatabase (const QString &dbName=QString::null)=0
virtual bool drv_useDatabase (const QString &dbName=QString::null, bool *cancelled=0, MessageHandler *msgHandler=0)=0
virtual bool drv_closeDatabase ()=0
virtual bool drv_isDatabaseUsed () const
virtual bool drv_dropDatabase (const QString &dbName=QString::null)=0
QString createTableStatement (const TableSchema &tableSchema) const
QString selectStatement (TableSchema &tableSchema, const SelectStatementOptions &options=SelectStatementOptions()) const
virtual bool drv_createTable (const QString &tableSchemaName)
virtual Q_ULLONG drv_lastInsertRowID ()=0
virtual TransactionDatadrv_beginTransaction ()
virtual bool drv_commitTransaction (TransactionData *trans)
virtual bool drv_rollbackTransaction (TransactionData *trans)
virtual bool drv_setAutoCommit (bool on)
bool beginAutoCommitTransaction (TransactionGuard &tg)
bool commitAutoCommitTransaction (const Transaction &trans)
bool rollbackAutoCommitTransaction (const Transaction &trans)
bool checkConnected ()
bool checkIsDatabaseUsed ()
TableSchemasetupTableSchema (const RowData &data)
QuerySchemasetupQuerySchema (const RowData &data)
bool updateRow (QuerySchema &query, RowData &data, RowEditBuffer &buf, bool useROWID=false)
bool insertRow (QuerySchema &query, RowData &data, RowEditBuffer &buf, bool getROWID=false)
bool deleteRow (QuerySchema &query, RowData &data, bool useROWID=false)
bool deleteAllRows (QuerySchema &query)
bool setupKexiDBSystemSchema ()
 Creates kexi__* tables.
TableSchemanewKexiDBSystemTableSchema (const QString &tsname)
QString escapeIdentifier (const QString &id, int drvEscaping=Driver::EscapeDriver|Driver::EscapeAsNecessary) const
 Identifier escaping function in the associated Driver.
void removeMe (TableSchema *ts)
bool checkIfColumnExists (Cursor *cursor, uint column)
tristate querySingleRecordInternal (RowData &data, const QString *sql, QuerySchema *query, bool addLimitTo1=true)
void setReadOnly (bool set)
bool loadExtendedTableSchemaData (TableSchema &tableSchema)
bool storeExtendedTableSchemaData (TableSchema &tableSchema)
bool storeMainFieldSchema (Field *field)
virtual tristate drv_changeFieldProperty (TableSchema &table, Field &field, const QString &propertyName, const QVariant &value)

Protected Attributes

QPtrDict< KexiDB::Cursorm_cursors
 cursors created for this connection

Friends

class KexiDB::Driver
class KexiDB::Cursor
class KexiDB::TableSchema
 for removeMe()
class KexiDB::DatabaseProperties
 for setError()
class ConnectionPrivate
class KexiDB::AlterTableHandler

Classes

class  SelectStatementOptions
 options used in selectStatement() More...
class  TableSchemaChangeListenerInterface


Constructor & Destructor Documentation

Connection::~Connection  )  [virtual]
 

Opened connection is automatically disconnected and removed from driver's connections list. Note for driver developers: you should call destroy() from you Connection's subclass destructor.

Definition at line 221 of file connection.cpp.

Connection::Connection Driver driver,
ConnectionData conn_data
[protected]
 

Used by Driver

Definition at line 198 of file connection.cpp.

References m_cursors, and KexiDB::Object::m_sql.


Member Function Documentation

tristate Connection::alterTable TableSchema tableSchema,
TableSchema newTableSchema
 

Todo:
(js): implement real altering

(js): update any structure (e.g.

query) that depend on this table!

Definition at line 1659 of file connection.cpp.

References clearError(), closeAllTableSchemaChangeListeners(), createTable(), ERR_OBJECT_THE_SAME, isEmpty(), KexiDB::SchemaData::name(), and KexiDB::Object::setError().

Referenced by KexiTableDesignerView::storeData().

bool Connection::alterTableName TableSchema tableSchema,
const QString newName,
bool  replace = false
 

Alters name of table described by tableSchema to newName. If replace is true, destination table is completely dropped and replaced by tableSchema, if present. In this case, identifier of tableSchema becomes equal to the dropped table's id, what can be useful if tableSchema was created with a temporary name and ID (used in AlterTableHandler).

If replace is false (the default) and destination table is present -- false is returned and ERR_OBJECT_EXISTS error is set. The schema of tableSchema is updated on success.

Returns:
true on success.

Definition at line 1685 of file connection.cpp.

References alterTableName_ERR, beginAutoCommitTransaction(), clearError(), commitAutoCommitTransaction(), dropTable(), drv_alterTableName(), ERR_INVALID_IDENTIFIER, ERR_OBJECT_EXISTS, ERR_OBJECT_NOT_FOUND, ERR_OBJECT_THE_SAME, KexiDB::Driver::escapeString(), executeSQL(), KexiDB::SchemaData::id(), KexiUtils::isIdentifier(), KexiDB::SchemaData::m_id, KexiDB::SchemaData::name(), KexiDB::Object::setError(), KexiDB::SchemaData::setName(), KexiDB::TableObjectType, tableSchema(), and KexiDB::TransactionGuard::transaction().

Referenced by KexiTablePart::rename().

QString Connection::anyAvailableDatabaseName  )  [virtual]
 

Returns:
name of any (e.g. first found) database for this connection. This method does not close or open this connection. The method can be used (it is also internally used, e.g. for database dropping) when we need a database name before we can connect and execute any SQL statement (e.g. DROP DATABASE).
The method can return nul lstring, but in this situation no automatic (implicit) connections could be made, what is useful by e.g. dropDatabase().

Note for driver developers: return here a name of database which you are sure is existing. Default implementation returns:

See decription of DriverBehaviour::ALWAYS_AVAILABLE_DATABASE_NAME member. You may want to reimplement this method only when you need to depend on this connection specifics (e.g. you need to check something remotely).

Definition at line 3006 of file connection.cpp.

References KexiDB::DriverBehaviour::ALWAYS_AVAILABLE_DATABASE_NAME, and KexiDB::Driver::beh.

Referenced by useDatabase(), and useTemporaryDatabaseIfNeeded().

bool Connection::autoCommit  )  const
 

Returns:
true if "auto commit" option is on.
When auto commit is on (the default on for any new Connection object), every sql functional statement (statement that changes data in the database implicitly starts a new transaction. This transaction is automatically committed after successful statement execution or rolled back on error.

For drivers that do not support transactions (see Driver::features()) this method shouldn't be called because it does nothing ans always returns false.

No internal KexiDB object should changes this option, although auto commit's behaviour depends on database engine's specifics. Engines that support only single transaction per connection (see Driver::SingleTransactions), use this single connection for autocommiting, so if there is already transaction started by the KexiDB user program (with beginTransaction()), this transaction is committed before any sql functional statement execution. In this situation default transaction is also affected (see defaultTransaction()).

Only for drivers that support nested transactions (Driver::NestedTransactions), autocommiting works independently from previously started transaction,

For other drivers set this option off if you need use transaction for grouping more statements together.

NOTE: nested transactions are not yet implemented in KexiDB API.

Definition at line 2058 of file connection.cpp.

bool Connection::beginAutoCommitTransaction TransactionGuard tg  )  [protected]
 

Internal, for handling autocommited transactions: begins transaction if one is supported.

Returns:
true if new transaction started successfully or no transactions are supported at all by the driver or if autocommit option is turned off. A handle to a newly created transaction (or null on error) is passed to tg parameter.
Special case when used database driver has only single transaction support (Driver::SingleTransactions): and there is already transaction started, it is committed before starting a new one, but only if this transaction has been started inside Connection object. (i.e. by beginAutoCommitTransaction()). Otherwise, a new transaction will not be started, but true will be returned immediately.

Definition at line 1855 of file connection.cpp.

References beginTransaction(), commitTransaction(), KexiDB::Driver::d, KexiDB::TransactionGuard::doNothing(), KexiDB::Object::error(), KexiDB::DriverPrivate::features, KexiDB::Driver::IgnoreTransactions, KexiDB::Driver::MultipleTransactions, KexiDB::TransactionGuard::setTransaction(), and KexiDB::Driver::SingleTransactions.

Referenced by alterTableName(), createTable(), dropQuery(), and dropTable().

Transaction Connection::beginTransaction  ) 
 

Creates new transaction handle and starts a new transaction.

Returns:
KexiDB::Transaction object if transaction has been started successfully, otherwise null transaction. For drivers that allow single transaction per connection (Driver::features() && SingleTransactions) this method can be called one time, and then this single transaction will be default ( setDefaultTransaction() will be called). For drivers that allow multiple transactions per connection, no default transaction is set automatically in beginTransaction() method, you could do this by hand.
See also:
setDefaultTransaction(), defaultTransaction().

Definition at line 1916 of file connection.cpp.

References checkIsDatabaseUsed(), KexiDB::Driver::d, drv_beginTransaction(), ERR_TRANSACTION_ACTIVE, KexiDB::DriverPrivate::features, KexiDB::Driver::IgnoreTransactions, KexiDB::Transaction::m_data, KexiDB::Driver::MultipleTransactions, KexiDB::Transaction::null, SET_BEGIN_TR_ERROR, SET_ERR_TRANS_NOT_SUPP, KexiDB::Object::setError(), and KexiDB::Driver::SingleTransactions.

Referenced by KexiCSVImportDialog::accept(), beginAutoCommitTransaction(), createDatabase(), and KexiMigration::KexiMigrate::performImport().

bool Connection::checkConnected  )  [protected]
 

Helper: checks if connection is established; if not: error message is set up and false returned

Definition at line 293 of file connection.cpp.

References clearError(), ERR_NO_CONNECTION, and KexiDB::Object::setError().

Referenced by closeDatabase(), createDatabase(), databaseExists(), databaseNames(), dropDatabase(), and useDatabase().

bool Connection::checkIfColumnExists Cursor cursor,
uint  column
[protected]
 

Definition at line 2300 of file connection.cpp.

References ERR_CURSOR_RECORD_FETCHING, KexiDB::Cursor::fieldCount(), and KexiDB::Object::setError().

Referenced by querySingleString(), and queryStringList().

bool Connection::checkIsDatabaseUsed  )  [protected]
 

Helper: checks both if connection is established and database any is used; if not: error message is set up and false returned

Definition at line 303 of file connection.cpp.

References clearError(), ERR_NO_DB_USED, isDatabaseUsed(), and KexiDB::Object::setError().

Referenced by beginTransaction(), createTable(), objectIds(), and objectNames().

void Connection::clearError  )  [virtual]
 

Reimplemented from Object: also clears sql string.

See also:
recentSQLString()

Reimplemented from KexiDB::Object.

Definition at line 267 of file connection.cpp.

References KexiDB::Object::clearError(), and KexiDB::Object::m_sql.

Referenced by alterTable(), alterTableName(), checkConnected(), checkIsDatabaseUsed(), commitTransaction(), connect(), createTable(), databaseExists(), deleteAllRows(), deleteRow(), disconnect(), dropQuery(), dropTable(), KexiDB::SQLiteConnection::drv_useDatabase(), insertRow(), querySchema(), queryStringList(), removeObject(), rollbackTransaction(), and updateRow().

tristate Connection::closeAllTableSchemaChangeListeners TableSchema tableSchema  ) 
 

Definition at line 3401 of file connection.cpp.

Referenced by alterTable(), KexiTablePart::askForClosingObjectsUsingTableSchema(), and dropTable().

bool Connection::closeDatabase  ) 
 

Closes currently used database for this connection.

Any active transactions (if supported) are rolled back, so commit these before closing, if you'd like to save your changes.

Definition at line 623 of file connection.cpp.

References checkConnected(), drv_closeDatabase(), KexiDBDbg, m_cursors, rollbackTransaction(), and KexiDB::Driver::transactionsSupported().

Referenced by createDatabase(), databaseExists(), databaseNames(), disconnect(), dropDatabase(), and useDatabase().

bool Connection::commitAutoCommitTransaction const Transaction trans  )  [protected]
 

Internal, for handling autocommited transactions: Commits transaction prevoiusly started with beginAutoCommitTransaction().

Returns:
true on success or when no transactions are supported at all by the driver.
Special case when used database driver has only single transaction support (Driver::SingleTransactions): if trans has been started outside Connection object (i.e. not by beginAutoCommitTransaction()), the transaction will not be committed.

Definition at line 1888 of file connection.cpp.

References commitTransaction(), KexiDB::Driver::d, KexiDB::DriverPrivate::features, KexiDB::Driver::IgnoreTransactions, KexiDB::Transaction::isNull(), KexiDB::Driver::SingleTransactions, and KexiDB::Driver::transactionsSupported().

Referenced by alterTableName(), createTable(), dropQuery(), and dropTable().

bool Connection::commitTransaction Transaction  trans = Transaction::null,
bool  ignore_inactive = false
 

Commits transaction trans. If there is not trans argument passed, and there is default transaction (obtained from defaultTransaction()) defined, this one will be committed. If default is not present, false is returned (when ignore_inactive is false, the default), or true is returned (when ignore_inactive is true).

On successful commit, trans object will be destroyed. If this was default transaction, there is no default transaction for now.

Definition at line 1954 of file connection.cpp.

References KexiDB::Transaction::active(), clearError(), KexiDB::Driver::d, drv_commitTransaction(), ERR_NO_TRANSACTION_ACTIVE, ERR_ROLLBACK_OR_COMMIT_TRANSACTION, KexiDB::Object::error(), KexiDB::DriverPrivate::features, KexiDB::Driver::IgnoreTransactions, isDatabaseUsed(), KexiDB::TransactionData::m_active, KexiDB::Transaction::m_data, KexiDB::Transaction::null, SET_ERR_TRANS_NOT_SUPP, KexiDB::Object::setError(), and KexiDB::Driver::transactionsSupported().

Referenced by beginAutoCommitTransaction(), commitAutoCommitTransaction(), createDatabase(), and KexiMigration::KexiMigrate::performImport().

bool Connection::connect  ) 
 

Connects to driver with given parameters.

Returns:
true if successful.

Definition at line 245 of file connection.cpp.

References clearError(), drv_connect(), ERR_ALREADY_CONNECTED, KexiDB::Driver::isFileDriver(), and KexiDB::Object::setError().

Referenced by KexiMigration::KexiMigrate::checkIfDestinationDatabaseOverwritingNeedsAccepting(), and KexiProjectSet::KexiProjectSet().

bool Connection::createDatabase const QString dbName  ) 
 

Creates new database with name dbName, using this connection.

If database with dbName already exists, or other error occurred, false is returned. For file-based drivers, dbName should be equal to the database filename (the same as specified for ConnectionData).

See doc/dev/kexidb_issues.txt document, chapter "Table schema, query schema, etc. storage" for database schema documentation (detailed description of kexi__* 'system' tables).

See also:
useDatabase()

Definition at line 434 of file connection.cpp.

References KexiDB::Transaction::active(), beginTransaction(), checkConnected(), closeDatabase(), commitTransaction(), createDatabase_CLOSE, createDatabase_ERROR, KexiDB::Driver::d, databaseExists(), drv_createDatabase(), drv_createTable(), ERR_OBJECT_EXISTS, ERR_SYSTEM_NAME_RESERVED, insertRecord(), KexiDB::DriverPrivate::isDBOpenedAfterCreate, KexiDB::Driver::isFileDriver(), KexiDB::Driver::isSystemDatabaseName(), KexiDB::Object::setError(), setupKexiDBSystemSchema(), tableSchema(), KexiDB::Driver::transactionsSupported(), useDatabase(), useTemporaryDatabaseIfNeeded(), and KexiDB::version().

bool Connection::createTable TableSchema tableSchema,
bool  replaceExisting = false
 

Creates a table according to the given schema.

Creates table defined by tableSchema. Schema information is also added into kexi system tables, for later reuse.

Returns:
true on success - tableSchema object is then inserted to Connection structures - it is owned by Connection object now, so you shouldn't destroy the tableSchema object by hand (or declare it as local-scope variable).
If replaceExisting is false (the default) and table with the same name (as tableSchema->name()) exists, false is returned. If replaceExisting is true, a table schema with the same name (if exists) is overwritten, then a new table schema gets the same identifier as existing table schema's identifier.

Note that on error:

  • tableSchema is not inserted into Connection's structures, so you are still owner of this object
  • existing table schema object is not destroyed (i.e. it is still available e.g. using Connection::tableSchema(const QString& ), even if the table was physically dropped.

Definition at line 1418 of file connection.cpp.

References beginAutoCommitTransaction(), buildValuesForKexi__Fields(), checkIsDatabaseUsed(), clearError(), commitAutoCommitTransaction(), createFieldListForKexi__Fields(), createTable_ERR, KexiDB::deleteRow(), dropTable(), drv_createTable(), ERR_CANNOT_CREATE_EMPTY_OBJECT, ERR_OBJECT_EXISTS, ERR_SYSTEM_NAME_RESERVED, KexiDB::FieldList::fieldCount(), KexiDB::FieldList::fields(), findSystemFieldName(), KexiDB::SchemaData::id(), insertInternalTableSchema(), insertRecord(), KexiDB::Driver::isSystemObjectName(), KexiDB::TableSchema::m_conn, KexiDB::SchemaData::m_id, KexiDB::Field::name(), KexiDB::SchemaData::name(), removeTableSchemaInternal(), KexiDB::Object::setError(), storeExtendedTableSchemaData(), storeObjectSchemaData(), and KexiDB::TransactionGuard::transaction().

Referenced by KexiCSVImportDialog::accept(), alterTable(), KexiMigration::KexiMigrate::performImport(), and KexiTableDesignerView::storeNewData().

QString Connection::createTableStatement const TableSchema tableSchema  )  const [protected]
 

Returns:
"CREATE TABLE ..." statement string needed for tableSchema creation in the database.
Note: The statement string can be specific for this connection's driver database, and thus not reusable in general.

Definition at line 870 of file connection.cpp.

References KexiDB::DriverBehaviour::AUTO_INCREMENT_FIELD_OPTION, KexiDB::DriverBehaviour::AUTO_INCREMENT_PK_FIELD_OPTION, KexiDB::DriverBehaviour::AUTO_INCREMENT_REQUIRES_PK, KexiDB::DriverBehaviour::AUTO_INCREMENT_TYPE, KexiDB::Driver::beh, KexiDB::Field::defaultValue(), escapeIdentifier(), field, KexiDB::Field::isAutoIncrement(), KexiDB::Field::isFPNumericType(), KexiDB::Field::isNotNull(), KexiDB::Field::isPrimaryKey(), KexiDB::Field::isUniqueKey(), KexiDB::Field::isUnsigned(), KexiDB::Field::length(), KexiDB::FieldList::m_fields, KexiDB::Field::name(), KexiDB::SchemaData::name(), KexiDB::Field::precision(), KexiDB::Field::scale(), KexiDB::DriverBehaviour::SPECIAL_AUTO_INCREMENT_DEF, KexiDB::Driver::sqlTypeName(), KexiDB::Field::Text, KexiDB::Field::type(), KexiDB::DriverBehaviour::UNSIGNED_TYPE_KEYWORD, and KexiDB::Driver::valueToSQL().

Referenced by drv_createTable().

QString Connection::currentDatabase  )  const
 

Get the name of the current database.

Returns:
name of currently used database for this connection or empty string if there is no used database

Definition at line 666 of file connection.cpp.

ConnectionData * Connection::data  )  const
 

Returns:
parameters that were used to create this connection.

Definition at line 240 of file connection.cpp.

Referenced by KexiDB::MySqlConnection::drv_connect(), KexiDB::SQLiteConnection::drv_createDatabase(), KexiDB::SQLiteConnection::drv_dropDatabase(), KexiDB::SQLiteConnection::drv_getDatabasesList(), KexiDB::SQLiteConnection::drv_useDatabase(), KexiDB::pqxxSqlConnection::drv_useDatabase(), KexiProject::KexiProject(), loadObjectSchemaData(), querySchema(), and tableSchema().

bool Connection::databaseExists const QString dbName,
bool  ignoreErrors = true
 

Returns:
true if database dbName exists. If ignoreErrors is true, error flag of connection won't be modified for any errors (it will quietly return), else (ignoreErrors == false) we can check why the database does not exist using error(), errorNum() and/or errorMsg().

Definition at line 372 of file connection.cpp.

References checkConnected(), clearError(), closeDatabase(), drv_databaseExists(), ERR_ACCESS_RIGHTS, ERR_OBJECT_NOT_FOUND, file, KexiDB::Driver::isFileDriver(), KexiDB::Object::setError(), and useTemporaryDatabaseIfNeeded().

Referenced by KexiMigration::KexiMigrate::checkIfDestinationDatabaseOverwritingNeedsAccepting(), createDatabase(), and useDatabase().

QStringList Connection::databaseNames bool  also_system_db = false  ) 
 

Returns:
list of database names for opened connection. If also_system_db is true, the system database names are also returned.

Definition at line 313 of file connection.cpp.

References checkConnected(), closeDatabase(), drv_getDatabasesList(), KexiDB::Driver::isSystemDatabaseName(), KexiDBDbg, and useTemporaryDatabaseIfNeeded().

Referenced by drv_databaseExists(), and KexiProjectSet::KexiProjectSet().

DatabaseProperties & Connection::databaseProperties  ) 
 

Returns:
DatabaseProperties object allowing to read and write global database properties for this connection.

Definition at line 831 of file connection.cpp.

KexiDB::DatabaseVersionInfo * Connection::databaseVersion  )  const
 

Returns:
version information for this connection. If database is not used (i.e. isDatabaseUsed() is false) 0 is returned. It can be compared to drivers' and KexiDB library version to maintain backward/upward compatiblility.

Definition at line 826 of file connection.cpp.

References isDatabaseUsed().

Transaction & Connection::defaultTransaction  )  const
 

Returns:
handle for default transaction for this connection or null transaction if there is no such a transaction defined. If transactions are supported: Any operation on database (e.g. inserts) that is started without specifying transaction context, will be performed in the context of this transaction.
Returned null transaction doesn't mean that there is no transactions started at all. Default transaction can be defined automatically for some drivers -- see beginTransaction().
See also:
KexiDB::Driver::transactionsSupported()

Definition at line 2034 of file connection.cpp.

bool Connection::deleteAllRows QuerySchema query  )  [protected]
 

Delete all existing rows.

Definition at line 3338 of file connection.cpp.

References clearError(), ERR_DELETE_SERVER_ERROR, escapeIdentifier(), executeSQL(), KexiDB::FieldList::fields(), KexiDBDbg, KexiDBWarn, KexiDB::Object::m_sql, KexiDB::QuerySchema::masterTable(), KexiDB::SchemaData::name(), KexiDB::TableSchema::primaryKey(), and KexiDB::Object::setError().

bool Connection::deleteCursor Cursor cursor  ) 
 

Deletes cursor cursor previously created by functions like executeQuery() for this connection. There is an attempt to close the cursor with Cursor::close() if it was opened. Anyway, at last cursor is deleted.

Returns:
true if cursor is properly closed before deletion.

Definition at line 2149 of file connection.cpp.

References KexiDBWarn.

Referenced by KexiPart::Manager::checkProject(), KexiFormView::deleteQuery(), KexiDB::SQLiteConnection::drv_getTablesList(), KexiDB::pqxxSqlConnection::drv_getTablesList(), KexiDB::MySqlConnection::drv_getTablesList(), KexiSimplePrintingEngine::init(), objectIds(), objectNames(), querySingleRecordInternal(), querySingleString(), queryStringList(), resultExists(), setupTableSchema(), and KexiFormView::~KexiFormView().

bool Connection::deleteRow QuerySchema query,
RowData data,
bool  useROWID = false
[protected]
 

Delete an existing row.

Definition at line 3272 of file connection.cpp.

References KexiDB::Driver::beh, KexiDB::Field::BigInteger, clearError(), ERR_DELETE_NO_ENTIRE_MASTER_TABLES_PKEY, ERR_DELETE_NO_MASTER_TABLE, ERR_DELETE_NO_MASTER_TABLES_PKEY, ERR_DELETE_NULL_PKEY_FIELD, ERR_DELETE_SERVER_ERROR, escapeIdentifier(), executeSQL(), KexiDB::FieldList::fieldCount(), KexiDB::FieldList::fieldsIterator(), KexiDBDbg, KexiDBWarn, KexiDB::Object::m_sql, KexiDB::QuerySchema::masterTable(), KexiDB::SchemaData::name(), KexiDB::QuerySchema::pkeyFieldsCount(), KexiDB::QuerySchema::pkeyFieldsOrder(), KexiDB::TableSchema::primaryKey(), KexiDB::DriverBehaviour::ROW_ID_FIELD_NAME, KexiDB::Object::setError(), and KexiDB::Driver::valueToSQL().

void Connection::destroy  )  [protected]
 

Method to be called form Connection's subclass destructor.

See also:
~Connection()

Definition at line 214 of file connection.cpp.

References KexiDB::DriverPrivate::connections, KexiDB::Driver::d, and disconnect().

Referenced by KexiDB::MySqlConnection::~MySqlConnection(), KexiDB::pqxxSqlConnection::~pqxxSqlConnection(), and KexiDB::SQLiteConnection::~SQLiteConnection().