#include <database.h>
Static Public Member Functions | |
| static DbAttach | getDatabases () |
| static DbObjects | getObjects (const QString type=0, const QString schema="main") |
| Gather user objects from sqlite_master by type. It skips the resrved names "sqlite_%". See getSysObjects(). | |
| static DbObjects | getSysObjects (const QString &schema="main") |
| Gather "SYS schema" objects. | |
| static QStringList | getSysIndexes (const QString &table, const QString &schema) |
| Gather "SYS indexes". System indexes are indexes created internally for UNIQUE constraints. | |
| static bool | execSql (QString statement) |
| Execute a SQL statement with no DB returns. | |
| static QString | sessionName (const QString &schema) |
| Create a session name for the new DB connection. | |
| static bool | dropTable (const QString &table, const QString &schema) |
| Drop a table from the database. | |
| static bool | dropTrigger (const QString &name, const QString &schema) |
| Drop a trigger from the database. | |
| static FieldList | tableFields (const QString &table, const QString &schema) |
| Returns the list of fields in a table. | |
| static QStringList | indexFields (const QString &index, const QString &schema) |
| Returns the list of columns in given index. | |
| static bool | dropView (const QString &view, const QString &schema) |
| Drop a view from the database. | |
| static bool | dropIndex (const QString &name, const QString &schema) |
| Drop an index from the database. | |
| static bool | exportSql (const QString &fileName) |
| Exports the SQL code of a database to file If the file provided by fileName exists, it will be overriden. | |
| static QString | describeObject (const QString &name, const QString &schema="main") |
| static QString | hex (const QByteArray &val) |
| BLOB X'foo' notation. See sqlite3 internals as a reference. | |
| static QString | pragma (const QString &name) |
| Query the DB for its specified PRAGMA setting. | |
The Database class represents a single database file/object, and provides convinient methods for accessing specific elements in it (currently only tables and views). Though the application still doesn't use this capability, it is completly safe to have multipile Database object managing diffirent databases in the same time.
Internally, the class uses the QtSQL API for manipulating the database.
Almost all methods here are static so it's not needed to create a Database instance.
| DbAttach Database::getDatabases | ( | ) | [static] |
References SESSION_NAME.
Referenced by TableTree::buildTree(), CreateViewDialog::CreateViewDialog(), ImportTableDialog::ImportTableDialog(), and TableEditorDialog::TableEditorDialog().
| DbObjects Database::getObjects | ( | const QString | type = 0, |
|
| const QString | schema = "main" | |||
| ) | [static] |
Gather user objects from sqlite_master by type. It skips the resrved names "sqlite_%". See getSysObjects().
| type | a "enum" 'table', 'view', index etc. If it's empty all objects are selected. | |
| schema | a name of the DB schema |
| DbObjects | a map with "object name"/"its parent" |
References SESSION_NAME.
Referenced by AnalyzeDialog::AnalyzeDialog(), TableTree::buildIndexes(), TableTree::buildTables(), TableTree::buildTriggers(), TableTree::buildViews(), getSysIndexes(), QueryEditorDialog::QueryEditorDialog(), and VacuumDialog::VacuumDialog().
| DbObjects Database::getSysObjects | ( | const QString & | schema = "main" |
) | [static] |
Gather "SYS schema" objects.
| schema | a string with "attached db" name |
| DbObjects | with With reserved names "sqlite_%". |
References SESSION_NAME.
Referenced by TableTree::buildCatalogue().
| QStringList Database::getSysIndexes | ( | const QString & | table, | |
| const QString & | schema | |||
| ) | [static] |
Gather "SYS indexes". System indexes are indexes created internally for UNIQUE constraints.
| table | a table name. | |
| schema | a string with "attached db" name |
| DbObjects | with With reserved names "sqlite_%". |
References getObjects(), and SESSION_NAME.
Referenced by TableTree::buildSysIndexes().
| bool Database::execSql | ( | QString | statement | ) | [static] |
Execute a SQL statement with no DB returns.
| statement | a SQL command like INSERT/CREATE/DROP. Selects are not important here. |
| bool | true on succes, false on error. Error are reported in this method already. |
References SESSION_NAME.
| QString Database::sessionName | ( | const QString & | schema | ) | [static] |
Create a session name for the new DB connection.
| schema | a schema name. |
| QString | string with "SQLITEMAN_schema" format. |
References SESSION_NAME.
| bool Database::dropTable | ( | const QString & | table, | |
| const QString & | schema | |||
| ) | [static] |
Drop a table from the database.
| table | The name of the table to drop | |
| schema | a table own schema |
| bool | true on success, false on error. Error are reported in this method already. |
References SESSION_NAME.
| bool Database::dropTrigger | ( | const QString & | name, | |
| const QString & | schema | |||
| ) | [static] |
Drop a trigger from the database.
| name | The name of the trigger to drop | |
| schema | a table own schema |
| bool | true on success, false on error. Error are reported in this method already. |
References SESSION_NAME.
| FieldList Database::tableFields | ( | const QString & | table, | |
| const QString & | schema | |||
| ) | [static] |
Returns the list of fields in a table.
| table | The table to retrive the fields from | |
| schema | a name of the DB schema |
References DatabaseTableField::cid, DatabaseTableField::comment, DatabaseTableField::defval, DatabaseTableField::name, DatabaseTableField::notnull, DatabaseTableField::pk, SESSION_NAME, and DatabaseTableField::type.
Referenced by TableTree::buildColumns(), ConstraintsDialog::ConstraintsDialog(), CreateIndexDialog::CreateIndexDialog(), and PopulatorDialog::PopulatorDialog().
| QStringList Database::indexFields | ( | const QString & | index, | |
| const QString & | schema | |||
| ) | [static] |
| bool Database::dropView | ( | const QString & | view, | |
| const QString & | schema | |||
| ) | [static] |
Drop a view from the database.
| view | The name of the view to drop | |
| schema | a table own schema |
| bool | true on success, false on error. Error are reported in this method already. |
References SESSION_NAME.
| bool Database::dropIndex | ( | const QString & | name, | |
| const QString & | schema | |||
| ) | [static] |
Drop an index from the database.
| name | The name of the index to drop | |
| schema | a table own schema |
| bool | true on success, false on error. Error are reported in this method already. |
References SESSION_NAME.
| bool Database::exportSql | ( | const QString & | fileName | ) | [static] |
Exports the SQL code of a database to file If the file provided by fileName exists, it will be overriden.
| fileName | The file to export the SQL to |
References SESSION_NAME.
| QString Database::describeObject | ( | const QString & | name, | |
| const QString & | schema = "main" | |||
| ) | [static] |
References SESSION_NAME.
| QString Database::hex | ( | const QByteArray & | val | ) | [static] |
BLOB X'foo' notation. See sqlite3 internals as a reference.
| val | a raw "encoded" QByteArray (string) |
| QString | with sqlite encoded X'blah' notation. |
| QString Database::pragma | ( | const QString & | name | ) | [static] |
Query the DB for its specified PRAGMA setting.
| name | a pragma name (PRAGMA name;) |
| QString | pragma value or "n/a" string if it is not set at all. |
References SESSION_NAME.
1.5.5