Database
Description
The Database object is the base class of all database objects. It contains a list of DatabaseTable objects and DatabaseSqlQuery objects.
- › Inherits:
- › Inherited by:
Overview
Properties
Methods
Signals
Enumerations
Properties
autoOpen
This property holds whether to automatically open a connection to the database.
- › Type:
Boolean
- › Default:
true- › Signal:
autoOpenChanged()
- › Attributes:
Writable
closeOnConnectionError
This property holds whether to automatically call close() whenever a connection error (Database.ConnectionError) occurs. In conjunction with autoOpen enabling this property allows implementing resilient database connections.
This property was introduced in InCore 1.1.
- › Type:
Boolean
- › Default:
true- › Signal:
closeOnConnectionErrorChanged()
- › Attributes:
Writable
debugSqlQueries
This property holds whether to log all executed SQL queries and resulting error messages to the console.
This property was introduced in InCore 1.1.
- › Type:
Boolean
- › Default:
false- › Signal:
debugSqlQueriesChanged()
- › Attributes:
Writable, Optional
error
This property holds the most recently occurred error or Database.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
- › Type:
- › Signal:
errorChanged()
- › Attributes:
Readonly
errorDetails
This property holds a human-readable database- or driver-specific description of the last error. It may provide additional information to errorString whenever an error occurs.
- › Type:
String
- › Attributes:
Readonly
errorString
This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.
- › Type:
String
- › Signal:
errorStringChanged()
- › Attributes:
Readonly
name
This property holds the name of the database to access. It depends on the actually used database implementation and the server configuration whether this property is honored or even required.
- › Type:
String
- › Signal:
nameChanged()
- › Attributes:
Writable
ready
This property holds whether the database has been opened successfully and is ready to execute queries.
This property was introduced in InCore 2.5.
- › Type:
Boolean
- › Default:
false- › Signal:
readyChanged()
- › Attributes:
Readonly
reopenInterval
This property holds the interval in milliseconds in which the database is reopened in case a connection is lost or failed. Set to 0 to disable this behaviour.
- › Type:
SignedInteger
- › Default:
60000- › Signal:
reopenIntervalChanged()
- › Attributes:
Writable
sqlQueries
This property holds a list of DatabaseSqlQuery objects.
- › Type:
- › Signal:
sqlQueriesChanged()
- › Attributes:
Readonly
tables
This property holds a list of DatabaseTable objects. Each table will be mapped to a table in the database file.
- › Type:
- › Signal:
tablesChanged()
- › Attributes:
Readonly
Methods
close()
This method closes the database and frees all internal resources.
This method was introduced in InCore 1.1.
dropAllTables()
This method removes all tables from the database. All tables are closed before being dropping.
- › Returns:
Boolean
open()
This method (re)opens the database. The internal database is recreated.
Signals
errorOccurred()
This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.
sqlQueriesDataChanged(SignedInteger index)
This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the sqlQueries list itself emitted the dataChanged() signal.
tablesDataChanged(SignedInteger index)
This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the tables list itself emitted the dataChanged() signal.
Enumerations
Error
This enumeration describes all errors which can occur in Database objects. The most recently occurred error is stored in the error property.
Name |
Value |
Description |
|---|---|---|
|
|
No error occurred or was detected. |
|
|
None or invalid storage set. |
|
|
Error while creating directories on storage. |
|
|
Can’t open database. |
|
|
Error while performing database initialization tasks. |
|
|
Failed to create tables in database. |
|
|
Some credentials are missing or invalid, e.g. no password set. |
|
|
None or invalid database name specified. |
|
|
Connection lost. |