Connection

class Connection : ObjectWrap , Lockable {}

Constructors

this
this(void* ptr, Flag!"Take" take)

Members

Functions

addEvent
void addEvent(gda.connection_event.ConnectionEvent event)

Adds an event to the given connection. This function is usually called by providers, to inform clients of events that happened during some operation.

addPreparedStatement
void addPreparedStatement(gda.statement.Statement gdaStmt, gda.pstmt.PStmt preparedStmt)

Declares that prepared_stmt is a prepared statement object associated to gda_stmt within the connection (meaning the connection increments the reference counter of prepared_stmt).

addSavepoint
bool addSavepoint(string name)

Adds a SAVEPOINT named name.

asyncCancel
bool asyncCancel(uint taskId)

Requests that a task be cancelled. This operation may of may not have any effect depending on the task's status, even if it returns true. If it returns false, then the task has not been cancelled.

asyncFetchResult
gobject.object.ObjectWrap asyncFetchResult(uint taskId, gda.set.Set lastInsertRow)

Use this method to obtain the result of the execution of a statement which has been executed asynchronously by calling gda.connection.Connection.asyncStatementExecute. This function is non locking and will return null (and no error will be set) if the statement has not been executed yet.

batchExecute
gobject.object.ObjectWrap[] batchExecute(gda.batch.Batch batch, gda.set.Set params, gda.types.StatementModelUsage modelUsage)

Executes all the statements contained in batch (in the order in which they were added to batch), and returns a list of #GObject objects, at most one #GObject for each statement; see gda.connection.Connection.statementExecute for details about the returned objects.

beginTransaction
bool beginTransaction(string name, gda.types.TransactionIsolation level)

Starts a transaction on the data source, identified by the name parameter.

clearEventsList
void clearEventsList()

This function lets you clear the list of #GdaConnectionEvent's of the given connection.

close
void close()

Closes the connection to the underlying data source, but first emits the "conn-to-close" signal.

closeNoWarning
void closeNoWarning()

Closes the connection to the underlying data source, without emiting any warning signal.

commitTransaction
bool commitTransaction(string name)

Commits the given transaction to the backend database. You need to call gda.connection.Connection.beginTransaction first.

connectConnClosed
ulong connectConnClosed(T callback, Flag!"After" after)

Connect to ConnClosed signal.

connectConnOpened
ulong connectConnOpened(T callback, Flag!"After" after)

Connect to ConnOpened signal.

connectConnToClose
ulong connectConnToClose(T callback, Flag!"After" after)

Connect to ConnToClose signal.

connectDsnChanged
ulong connectDsnChanged(T callback, Flag!"After" after)

Connect to DsnChanged signal.

connectError
ulong connectError(T callback, Flag!"After" after)

Connect to Error signal.

connectTransactionStatusChanged
ulong connectTransactionStatusChanged(T callback, Flag!"After" after)

Connect to TransactionStatusChanged signal.

createOperation
gda.server_operation.ServerOperation createOperation(gda.types.ServerOperationType type, gda.set.Set options)

Creates a new #GdaServerOperation object which can be modified in order to perform the type type of action. It is a wrapper around the gda.server_provider.ServerProvider.createOperation method.

createParser
gda.sql_parser.SqlParser createParser()

Creates a new parser object able to parse the SQL dialect understood by cnc. If the #GdaServerProvider object internally used by cnc does not have its own parser, then null is returned, and a general SQL parser can be obtained using gda.sql_parser.SqlParser.new_.

delPreparedStatement
void delPreparedStatement(gda.statement.Statement gdaStmt)

Removes any prepared statement associated to gda_stmt in cnc: this undoes what gda.connection.Connection.addPreparedStatement does.

deleteRowFromTable
bool deleteRowFromTable(string table, string conditionColumnName, gobject.value.Value conditionValue)

This is a convenience function, which creates a DELETE statement and executes it using the values provided. It internally relies on variables which makes it immune to SQL injection problems.

deleteSavepoint
bool deleteSavepoint(string name)

Delete the SAVEPOINT named name when not used anymore.

executeNonSelectCommand
int executeNonSelectCommand(string sql)

This is a convenience function to execute a SQL command over the opened connection. For the returned value, see gda.connection.Connection.statementExecuteNonSelect's documentation.

executeSelectCommand
gda.data_model.DataModel executeSelectCommand(string sql)

Execute a SQL SELECT command over an opened connection.

getAuthentication
string getAuthentication()

Gets the user name used to open this connection.

getCncString
string getCncString()

Gets the connection string used to open this connection.

getDateFormat
bool getDateFormat(glib.types.DateDMY outFirst, glib.types.DateDMY outSecond, glib.types.DateDMY outThird, char outSep)

This function allows you to determine the actual format for the date values.

getDsn
string getDsn()
getEvents
gda.connection_event.ConnectionEvent[] getEvents()

Retrieves a list of the last errors occurred during the connection. The returned list is chronologically ordered such as that the most recent event is the #GdaConnectionEvent of the first node.

getMetaStore
gda.meta_store.MetaStore getMetaStore()

Get or initializes the #GdaMetaStore associated to cnc

getMetaStoreDataV
gda.data_model.DataModel getMetaStoreDataV(gda.types.ConnectionMetaType metaType, gda.holder.Holder[] filters)

see #gda_connection_get_meta_store_data

getOptions
gda.types.ConnectionOptions getOptions()

Gets the #GdaConnectionOptions used to open this connection.

getPreparedStatement
gda.pstmt.PStmt getPreparedStatement(gda.statement.Statement gdaStmt)

Retrieves a pointer to an object representing a prepared statement for gda_stmt within cnc. The association must have been done using gda.connection.Connection.addPreparedStatement.

getProvider
gda.server_provider.ServerProvider getProvider()

Gets a pointer to the #GdaServerProvider object used to access the database

getProviderName
string getProviderName()

Gets the name (identifier) of the database provider used by cnc

getTransactionStatus
gda.transaction_status.TransactionStatus getTransactionStatus()

Get the status of cnc regarding transactions. The returned object should not be modified or destroyed; however it may be modified or destroyed by the connection itself.

insertRowIntoTableV
bool insertRowIntoTableV(string table, string[] colNames, gobject.value.Value[] values)

col_names and values must have length (>= 1).

isOpened
bool isOpened()

Checks whether a connection is open or not.

open
bool open()

Tries to open the connection.

parseSqlString
gda.statement.Statement parseSqlString(string sql, gda.set.Set params)

This function helps to parse a SQL string which uses parameters and store them at params.

performOperation
bool performOperation(gda.server_operation.ServerOperation op)

Performs the operation described by op (which should have been created using gda.connection.Connection.createOperation). It is a wrapper around the gda.server_provider.ServerProvider.performOperation method.

pointAvailableEvent
gda.connection_event.ConnectionEvent pointAvailableEvent(gda.types.ConnectionEventType type)

Use this method to get a pointer to the next available connection event which can then be customized and taken into account using gda.connection.Connection.addEvent.

quoteSqlIdentifier
string quoteSqlIdentifier(string id)

Use this method to get a correctly quoted (if necessary) SQL identifier which can be used in SQL statements, from id. If id is already correctly quoted for cnc, then a copy of id may be returned.

rollbackSavepoint
bool rollbackSavepoint(string name)

Rollback all the modifications made after the SAVEPOINT named name.

rollbackTransaction
bool rollbackTransaction(string name)

Rollbacks the given transaction. This means that all changes made to the underlying data source since the last call to #gda.connection.Connection.beginTransaction or #gda.connection.Connection.commitTransaction will be discarded.

self
Connection self()

Returns this, for use in with statements.

statementExecute
gobject.object.ObjectWrap statementExecute(gda.statement.Statement stmt, gda.set.Set params, gda.types.StatementModelUsage modelUsage, gda.set.Set lastInsertRow)

Executes stmt.

statementExecuteNonSelect
int statementExecuteNonSelect(gda.statement.Statement stmt, gda.set.Set params, gda.set.Set lastInsertRow)

Executes a non-selection statement on the given connection.

statementExecuteSelect
gda.data_model.DataModel statementExecuteSelect(gda.statement.Statement stmt, gda.set.Set params)

Executes a selection command on the given connection.

statementPrepare
bool statementPrepare(gda.statement.Statement stmt)

Ask the database accessed through the cnc connection to prepare the usage of stmt. This is only useful if stmt will be used more than once (however some database providers may always prepare statements before executing them).

statementToSql
string statementToSql(gda.statement.Statement stmt, gda.set.Set params, gda.types.StatementSqlFlag flags, gda.holder.Holder[] paramsUsed)

Renders stmt as an SQL statement, adapted to the SQL dialect used by cnc

supportsFeature
bool supportsFeature(gda.types.ConnectionFeature feature)

Asks the underlying provider for if a specific feature is supported.

updateMetaStore
bool updateMetaStore(gda.meta_context.MetaContext context)

Updates cnc's associated #GdaMetaStore. If context is not null, then only the parts described by context will be updated, and if it is null, then the complete meta store will be updated. Detailed explanations follow:

updateRowInTableV
bool updateRowInTableV(string table, string conditionColumnName, gobject.value.Value conditionValue, string[] colNames, gobject.value.Value[] values)

col_names and values must have length (>= 1).

valueToSqlString
string valueToSqlString(gobject.value.Value from)

Produces a fully quoted and escaped string from a GValue

Properties

_gType
GType _gType [@property getter]
authString
string authString [@property getter]
authString
string authString [@property setter]
cncString
string cncString [@property getter]
cncString
string cncString [@property setter]
dsn
string dsn [@property getter]
dsn
string dsn [@property setter]
eventsHistorySize
int eventsHistorySize [@property getter]

Get eventsHistorySize property.

eventsHistorySize
int eventsHistorySize [@property setter]

Set eventsHistorySize property.

executionSlowdown
uint executionSlowdown [@property getter]

Get executionSlowdown property.

executionSlowdown
uint executionSlowdown [@property setter]

Set executionSlowdown property.

executionTimer
bool executionTimer [@property getter]

Get executionTimer property.

executionTimer
bool executionTimer [@property setter]

Set executionTimer property.

isWrapper
bool isWrapper [@property getter]

Get isWrapper property.

isWrapper
bool isWrapper [@property setter]

Set isWrapper property.

metaStore
gda.meta_store.MetaStore metaStore [@property getter]
metaStore
gda.meta_store.MetaStore metaStore [@property setter]
monitorWrappedInMainloop
bool monitorWrappedInMainloop [@property getter]

Get monitorWrappedInMainloop property.

monitorWrappedInMainloop
bool monitorWrappedInMainloop [@property setter]

Set monitorWrappedInMainloop property.

provider
gda.server_provider.ServerProvider provider [@property getter]
provider
gda.server_provider.ServerProvider provider [@property setter]
threadOwner
void* threadOwner [@property getter]
threadOwner
void* threadOwner [@property setter]

Static functions

_getGType
GType _getGType()
errorQuark
glib.types.Quark errorQuark()
newFromDsn
gda.connection.Connection newFromDsn(string dsn, string authString, gda.types.ConnectionOptions options)

This function is similar to gda.connection.Connection.openFromDsn, except it does not actually open the connection, you have to open it using gda.connection.Connection.open.

newFromString
gda.connection.Connection newFromString(string providerName, string cncString, string authString, gda.types.ConnectionOptions options)

This function is similar to gda.connection.Connection.openFromString, except it does not actually open the connection, you have to open it using gda.connection.Connection.open.

openFromDsn
gda.connection.Connection openFromDsn(string dsn, string authString, gda.types.ConnectionOptions options)

This function is the way of opening database connections with libgda, using a pre-defined data source (DSN), see gda.config.Config.defineDsn for more information about how to define a DSN. If you don't want to define a DSN, it is possible to use gda.connection.Connection.openFromString instead of this method.

openFromString
gda.connection.Connection openFromString(string providerName, string cncString, string authString, gda.types.ConnectionOptions options)

Opens a connection given a provider ID and a connection string. This allows applications to open connections without having to create a data source (DSN) in the configuration. The format of cnc_string is similar to PostgreSQL and MySQL connection strings. It is a semicolumn-separated series of <key>=<value> pairs, where each key and value are encoded as per RFC 1738, see gda.global.rfc1738Encode for more information.

openSqlite
gda.connection.Connection openSqlite(string directory, string filename, bool autoUnlink)

Opens an SQLite connection even if the SQLite provider is not installed, to be used by database providers which need a temporary database to store some information.

stringSplit
void stringSplit(string string_, string outCncParams, string outProvider, string outUsername, string outPassword)

Extract the provider, connection parameters, username and password from string. in string, the various parts are strings which are expected to be encoded using an RFC 1738 compliant encoding. If they are specified, the returned provider, username and password strings are correctly decoded.

Mixed In Members

From mixin LockableT!()

lock
void lock()

Locks lockable. If it is already locked by another thread, the current thread will block until it is unlocked by the other thread.

trylock
bool trylock()

Tries to lock lockable. If it is already locked by another thread, then it immediately returns FALSE, otherwise it locks lockable.

unlock
void unlock()

Unlocks lockable. This method should not be called if the current does not already holds a lock on lockable (having used gda.lockable.Lockable.lock or gda.lockable.Lockable.trylock).

Inherited Members

From ObjectWrap

_setGObject
void _setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectWrap wrapper.

_cPtr
void* _cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

_ref
void* _ref(void* gObj)

Calls g_object_ref() on a GObject.

_unref
_unref(void* gObj)

Calls g_object_unref() on a GObject.

_getGType
GType _getGType()

Get the GType of an object.

_gType
GType _gType [@property getter]

GObject GType property.

self
ObjectWrap self()

Convenience method to return this cast to a type. For use in D with statements.

_getDObject
T _getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
ulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectWrap.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectWrap.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectWrap refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectWrap.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectWrap.ref_ and gobject.object.ObjectWrap.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
ulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.

From Lockable

_getGType
GType _getGType()
lock
void lock()

Locks lockable. If it is already locked by another thread, the current thread will block until it is unlocked by the other thread.

trylock
bool trylock()

Tries to lock lockable. If it is already locked by another thread, then it immediately returns FALSE, otherwise it locks lockable.

unlock
void unlock()

Unlocks lockable. This method should not be called if the current does not already holds a lock on lockable (having used gda.lockable.Lockable.lock or gda.lockable.Lockable.trylock).