Gjsify LogoGjsify Logo

Hierarchy

Index

Constructors

Properties

Methods

Constructors

Properties

auth_string: string
cnc_string: string
dsn: string
events_history_size: number

Defines the number of #GdaConnectionEvent objects kept in memory which can be fetched using gda_connection_get_events().

execution_slowdown: number

Artificially slows down the execution of queries. This property can be used to debug some problems. If non zero, this value is the number of microseconds waited before actually executing each query. NB: this parameter is ignored during the meta store update (it is set to 0 before the meta data update and restored to its state after).

execution_timer: boolean

Computes execution times for each statement executed.

g_type_instance: TypeInstance
meta_store: Gda.MetaStore
parent_instance: GObject.Object
name: string

Methods

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

    As soon as a provider (or a client, it does not matter) calls this function with an event object which is an error, the connection object emits the "error" signal, to which clients can connect to be informed of events.

    WARNING: the reference to the event object is stolen by this function!

    Parameters

    Returns void

  • 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).

    If gda_stmt changes or is destroyed, the the association will be lost and the connection will lose the reference it has on prepared_stmt.

    Parameters

    • gda_stmt: Gda.Statement

      a #GdaStatement object

    • prepared_stmt: Gda.PStmt

      a prepared statement object (as a #GdaPStmt object, or more likely a descendant)

    Returns void

  • add_savepoint(name: string): boolean
  • 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_statement_execute() for details about the returned objects.

    If one of the statement fails, then none of the subsequent statement will be executed, and the method returns the list of #GObject created by the correct execution of the previous statements. If a transaction is required, then it should be started before calling this method.

    Parameters

    • batch: Gda.Batch

      a #GdaBatch object which contains all the statements to execute

    • params: Gda.Set

      a #GdaSet object (which can be obtained using gda_batch_get_parameters()), or %NULL

    • model_usage: Gda.StatementModelUsage

      specifies how the returned data model(s) will be used, as a #GdaStatementModelUsage enum

    Returns GObject.Object[]

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

    Before starting a transaction, you can check whether the underlying provider does support transactions or not by using the gda_connection_supports_feature() function.

    Parameters

    • name: string

      the name of the transation to start, or %NULL

    • level: Gda.TransactionIsolation

      the requested transaction level (use %GDA_TRANSACTION_ISOLATION_SERVER_DEFAULT to apply the server default)

    Returns boolean

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

    Whenever the source_property is changed the target_property is updated using the same value. For instance:

      g_object_bind_property (action, "active", widget, "sensitive", 0);
    

    Will result in the "sensitive" property of the widget #GObject instance to be updated with the same value of the "active" property of the action #GObject instance.

    If flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.

    The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned #GBinding instance.

    Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.

    A #GObject can have multiple bindings.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target #GObject

    • target_property: string

      the property on target to bind

    • flags: BindingFlags

      flags to pass to #GBinding

    Returns Binding

  • 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.

    This function is the language bindings friendly version of g_object_bind_property_full(), using #GClosures instead of function pointers.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target #GObject

    • target_property: string

      the property on target to bind

    • flags: BindingFlags

      flags to pass to #GBinding

    • transform_to: TClosure<any, any>

      a #GClosure wrapping the transformation function from the source to the target, or %NULL to use the default

    • transform_from: TClosure<any, any>

      a #GClosure wrapping the transformation function from the target to the source, or %NULL to use the default

    Returns Binding

  • clear_events_list(): void
  • This function lets you clear the list of #GdaConnectionEvent's of the given connection.

    Returns void

  • close(): boolean
  • commit_transaction(name: string): boolean
  • Commits the given transaction to the backend database. You need to call gda_connection_begin_transaction() first.

    Parameters

    • name: string

      the name of the transation to commit, or %NULL

    Returns boolean

  • A convenient method to create a new #GdaDbCatalog instance and set the current cnc as a property. If for some reason, this approach doesn't fit well, the same task can be achieved by the following code:

    GdaDbCatalog *catalog = gda_db_catalog_new (); g_object_set (catalog, "connection", cnc, NULL);

    Returns DbCatalog

  • 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_new().

    Returns Gda.SqlParser

  • Removes any prepared statement associated to gda_stmt in cnc: this undoes what gda_connection_add_prepared_statement() does.

    Parameters

    Returns void

  • delete_row_from_table(table: string, condition_column_name: string, condition_value: any): boolean
  • 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.

    The equivalent SQL command is: DELETE FROM <table> WHERE <condition_column_name> = <condition_value>.

    A simple example to remove a row in database.


    GdaConnection *cnc;
    //Open connection here

    GError *error = NULL;

    GValue *v_id = gda_value_new (G_TYPE_INT);
    GValue *v_name = gda_value_new_from_string ("Aldibino Refinino", G_TYPE_STRING);

    //The number 10 represents a primary key record in the table
    g_value_set_int (v_id, 10);

    //Delete a record with a specific ID in the col_id column
    if (!gda_connection_delete_row_from_table (cnc, "TABLE_CONTACTS",
    "col_id", v_id,
    &error))
    {
    g_error ("Could not delete row in table: %s\n",
    error && error->message ? error->message : "No detail");
    }

    //Delete a record with a specific NAME in the col_name column
    if (!gda_connection_delete_row_from_table (cnc, "TABLE_CONTACTS",
    "col_name", v_name,
    &error))
    {
    g_error ("Could not delete row in table: %s\n",
    error && error->message ? error->message : "No detail");
    }

    gda_value_free (v_id);
    gda_value_free (v_name);

    g_error_free (error);

    Parameters

    • table: string

      the table's name with the row's values to be updated

    • condition_column_name: string

      the name of the column to used in the WHERE condition clause

    • condition_value: any

      the condition_column_type's GType

    Returns boolean

  • delete_savepoint(name: string): boolean
  • Delete the SAVEPOINT named name when not used anymore.

    Parameters

    • name: string

      name of the savepoint to delete

    Returns boolean

  • disconnect(id: number): void
  • emit(sigName: "closed", ...args: any[]): void
  • emit(sigName: "dsn-changed", ...args: any[]): void
  • emit(sigName: "error", event: Gda.ConnectionEvent, ...args: any[]): void
  • emit(sigName: "opened", ...args: any[]): void
  • emit(sigName: "status-changed", status: Gda.ConnectionStatus, ...args: any[]): void
  • emit(sigName: "transaction-status-changed", ...args: any[]): void
  • emit(sigName: "notify::auth-string", ...args: any[]): void
  • emit(sigName: "notify::cnc-string", ...args: any[]): void
  • emit(sigName: "notify::dsn", ...args: any[]): void
  • emit(sigName: "notify::events-history-size", ...args: any[]): void
  • emit(sigName: "notify::execution-slowdown", ...args: any[]): void
  • emit(sigName: "notify::execution-timer", ...args: any[]): void
  • emit(sigName: "notify::meta-store", ...args: any[]): void
  • emit(sigName: "notify::provider", ...args: any[]): void
  • emit(sigName: string, ...args: any[]): void
  • execute_non_select_command(sql: string): number
  • This is a convenience function to execute a SQL command over the opened connection. For the returned value, see gda_connection_statement_execute_non_select()'s documentation.

    Parameters

    • sql: string

      a query statement that must not begin with "SELECT"

    Returns number

  • force_floating(): void
  • 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 g_object_ref_sink().

    Returns void

  • freeze_notify(): void
  • 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.

    This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

    Returns void

  • get_authentication(): string
  • get_cnc_string(): string
  • Gets the connection string used to open this connection.

    The connection string is the string sent over to the underlying database provider, which describes the parameters to be used to open a connection on the underlying data source.

    Returns string

  • get_data(key?: string): object
  • Gets a named field from the objects table of associations (see g_object_set_data()).

    Parameters

    • Optional key: string

      name of the key for that association

    Returns object

  • get_dsn(): string
  • 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.

    Warning: the cnc object may change the list if connection events occur

    Returns Gda.ConnectionEvent[]

  • Get the #GMainContext used while a potentially blocking operation is performed using nc, see gda_connection_set_main_context(). If cnc is %NULL, then the setting applies to all the connections for which no other similar setting has been set.

    If no main context has been defined, then some function calls (for example connection opening) may block until the operation has finished.

    Parameters

    • thread: Thread

      the #GThread in which context will be used, or %NULL (for the current thread)

    Returns MainContext

  • Retrieves a pointer to an object representing a prepared statement for gda_stmt within cnc. The association must have been done using gda_connection_add_prepared_statement().

    Parameters

    Returns Gda.PStmt

  • get_property(property_name?: string, value?: any): void
  • Gets a property of an object.

    The value can be:

    • an empty #GValue initialized by %G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a #GValue initialized with the expected type of the property
    • a #GValue initialized with a type to which the expected type of the property can be transformed

    In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling g_value_unset().

    Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.

    Parameters

    • Optional property_name: string

      the name of the property to get

    • Optional value: any

      return location for the property value

    Returns void

  • get_provider_name(): string
  • get_qdata(quark: number): object
  • 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.

    If %NULL is returned, then no transaction has been associated with cnc

    Returns Gda.TransactionStatus

  • getv(names: string[], values: any[]): void
  • 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.

    Parameters

    • names: string[]

      the names of each property to get

    • values: any[]

      the values of each property to get

    Returns void

  • insert_row_into_table_v(table: string, col_names: string[], values: any[]): boolean
  • col_names and values must have length (>= 1).

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

    The equivalent SQL command is: INSERT INTO <table> (<column_name> [,...]) VALUES (<column_name> = <new_value> [,...]).

    Parameters

    • table: string

      table's name to insert into

    • col_names: string[]

      a list of column names (as const gchar *)

    • values: any[]

      a list of values (as #GValue)

    Returns boolean

  • internal_reset_transaction_status(): void
  • internal_savepoint_added(parent_trans: string, svp_name: string): void
  • Internal functions to be called by database providers when a savepoint has been added to keep track of the transaction status of the connection

    Note: this function should not be called if gda_connection_internal_statement_executed() has already been called because a statement's execution was necessary to perform the action.

    Parameters

    • parent_trans: string

      name of the parent transaction, or %NULL

    • svp_name: string

      savepoint's name, or %NULL

    Returns void

  • internal_savepoint_removed(svp_name: string): void
  • Internal functions to be called by database providers when a savepoint has been removed to keep track of the transaction status of the connection

    Note: this function should not be called if gda_connection_internal_statement_executed() has already been called because a statement's execution was necessary to perform the action.

    Parameters

    • svp_name: string

      savepoint's name, or %NULL

    Returns void

  • internal_savepoint_rolledback(svp_name: string): void
  • Internal functions to be called by database providers when a savepoint has been rolled back to keep track of the transaction status of the connection

    Note: this function should not be called if gda_connection_internal_statement_executed() has already been called because a statement's execution was necessary to perform the action.

    Parameters

    • svp_name: string

      savepoint's name, or %NULL

    Returns void

  • Note: calling this function more than once will not make it call destroy_func on any previously set opaque data, you'll have to do it yourself.

    Note: destroy_func, needs to free the memory associated to data, if necessary.

    Parameters

    • data: ServerProviderConnectionData

      a #GdaServerProviderConnectionData, which can be extended as needed by the provider for which cnc is opened

    • destroy_func: GLib.DestroyNotify

      function to call when the connection closes and data needs to be destroyed

    Returns void

  • Internal functions to be called by database providers when a statement has been executed to keep track of the transaction status of the connection

    Parameters

    • stmt: Gda.Statement

      a #GdaStatement which has been executed

    • params: Gda.Set

      execution's parameters

    • error: Gda.ConnectionEvent

      a #GdaConnectionEvent if the execution failed, or %NULL

    Returns void

  • internal_transaction_committed(trans_name: string): void
  • Internal functions to be called by database providers when a transaction has been committed to keep track of the transaction status of the connection

    Note: this function should not be called if gda_connection_internal_statement_executed() has already been called because a statement's execution was necessary to perform the action.

    Parameters

    • trans_name: string

      transaction's name, or %NULL

    Returns void

  • internal_transaction_rolledback(trans_name: string): void
  • Internal functions to be called by database providers when a transaction has been rolled back to keep track of the transaction status of the connection

    Note: this function should not be called if gda_connection_internal_statement_executed() has already been called because a statement's execution was necessary to perform the action.

    Parameters

    • trans_name: string

      transaction's name, or %NULL

    Returns void

  • Internal functions to be called by database providers when a transaction has been started to keep track of the transaction status of the connection.

    Note: this function should not be called if gda_connection_internal_statement_executed() has already been called because a statement's execution was necessary to perform the action.

    Parameters

    • parent_trans: string

      name of the parent transaction, or %NULL

    • trans_name: string

      transaction's name, or %NULL

    • isol_level: Gda.TransactionIsolation

      isolation level.

    Returns void

  • is_floating(): boolean
  • is_opened(): boolean
  • lock(): void
  • Locks lockable. If it is already locked by another thread, the current thread will block until it is unlocked by the other thread.

    Note: unlike g_mutex_lock(), this method recursive, which means a thread can lock lockable several times (and has to unlock it as many times to actually unlock it).

    Returns void

  • notify(property_name: string): void
  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    • property_name: string

      the name of a property installed on the class of object.

    Returns void

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

    This function omits the property name lookup, hence it is faster than g_object_notify().

    One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:

      enum
    {
    PROP_0,
    PROP_FOO,
    PROP_LAST
    };

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
    0, 100,
    50,
    G_PARAM_READWRITE);
    g_object_class_install_property (gobject_class,
    PROP_FOO,
    properties[PROP_FOO]);
    }

    and then notify a change on the "foo" property with:

      g_object_notify_by_pspec (self, properties[PROP_FOO]);
    

    Parameters

    • pspec: ParamSpec

      the #GParamSpec of a property installed on the class of object.

    Returns void

  • open(): boolean
  • Tries to open the connection. The function either blocks or, if a #GMaincontext has been specified using gda_connection_set_main_context(), processes the events for that main context until either the connection opening has succeeded or failed.

    If the connection is already opened, then this function returns %TRUE immediately.

    Returns boolean

  • This function requests that the connection be opened.

    If the connection is already opened, then this function returns an error (with the %GDA_CONNECTION_ALREADY_OPENED_ERROR code).

    Note: callback function will be called when processing events from the #GMainContext defined by gda_connection_set_main_context(), for example when there is a main loop for that main context.

    Parameters

    • callback: ConnectionOpenFunc

      a #GdaConnectionOpenFunc which will be called after the connection has been opened (of failed to open)

    Returns number

  • This method is similar to gda_server_operation_get_value_at(), but for SQL identifiers: a new string is returned instead of a #GValue. Also the returned string is assumed to represents an SQL identifier and will correctly be quoted to be used with cnc.

    Parameters

    • op: Gda.ServerOperation

      a #GdaServerOperation object

    • path: string

      a complete path to a node (starting with "/")

    Returns string

  • Performs the operation described by op (which should have been created using gda_connection_create_operation()). It is a wrapper around the gda_server_provider_perform_operation() method.

    Parameters

    Returns boolean

  • Add more arguments if the flag needs them:

    GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG: string with the table's name referenced an integer with the number pairs "local_field", "referenced_field" used in the reference Pairs of "local_field", "referenced_field" to use, must match the number specified above. a string with the action for ON DELETE; can be: "RESTRICT", "CASCADE", "NO ACTION", "SET NULL" and "SET DEFAULT". Example: "ON UPDATE CASCADE". a string with the action for ON UPDATE (see above).

    Create a #GdaServerOperation object using an opened connection, taking three arguments, a column's name the column's GType and #GdaServerOperationCreateTableFlag flag, you need to finish the list using %NULL.

    You'll be able to modify the #GdaServerOperation object to add custom options to the operation. When finished call #gda_server_operation_perform_create_table or #gda_server_provider_perform_operation in order to execute the operation.

    Parameters

    • table_name: string

      name of the table to create

    • arguments_: ServerOperationCreateTableArg[]

      list of arguments as #GdaServerOperationPrepareCreateTableArg containing column's name, column's #GType and a #GdaServerOperationCreateTableFlag flag

    Returns Gda.ServerOperation

  • This is just a convenient function to create a #GdaServerOperation to drop a table in an opened connection.

    Parameters

    • table_name: string

      name of the table to drop

    Returns Gda.ServerOperation

  • quote_sql_identifier(id: string): string
  • 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.

    This method may add double quotes (or other characters) around id: if id is a reserved SQL keyword (such as SELECT, INSERT, ...) if id contains non allowed characters such as spaces, or if it starts with a digit in any other event as necessary for cnc, depending on the the options passed when opening the cnc connection, and specifically the GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE option.

    One can safely pass an already quoted id to this method, either with quoting characters allowed by cnc or using the double quote (") character.

    Parameters

    • id: string

      an SQL identifier

    Returns string

  • Increases the reference count of object.

    Since GLib 2.56, if GLIB_VERSION_MAX_ALLOWED is 2.56 or greater, the type of object will be propagated to the return type (using the GCC typeof() extension), so any casting the caller needs to do on the return type must be explicit.

    Returns GObject.Object

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

    In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

    Since GLib 2.56, the type of object will be propagated to the return type under the same conditions as for g_object_ref().

    Returns GObject.Object

  • Executes the statement upon which rstmt is built. Note that as several statements can actually be executed by this method, it is recommended to be within a transaction.

    If error is not %NULL and stop_on_error is %FALSE, then it may contain the last error which occurred.

    Parameters

    • rstmt: Gda.RepetitiveStatement

      a #GdaRepetitiveStatement object

    • model_usage: Gda.StatementModelUsage

      specifies how the returned data model will be used as a #GdaStatementModelUsage enum

    • col_types: GType<unknown>[]

      an array of GType to request each returned GdaDataModel's column's GType, see gda_connection_statement_execute_select_full() for more information

    • stop_on_error: boolean

      set to TRUE if the method has to stop on the first error.

    Returns GObject.Object[]

  • rollback_savepoint(name: string): boolean
  • Rollback all the modifications made after the SAVEPOINT named name.

    Parameters

    • name: string

      name of the savepoint to rollback to

    Returns boolean

  • rollback_transaction(name: string): boolean
  • Rollbacks the given transaction. This means that all changes made to the underlying data source since the last call to #gda_connection_begin_transaction() or #gda_connection_commit_transaction() will be discarded.

    Parameters

    • name: string

      the name of the transation to commit, or %NULL

    Returns boolean

  • run_dispose(): void
  • Releases all references to other objects. This can be used to break reference cycles.

    This function should only be called from object system implementations.

    Returns void

  • set_data(key: string, data?: object): void
  • Each object carries around a table of associations from strings to pointers. This function lets you set an association.

    If the object already had an association with that name, the old association will be destroyed.

    Internally, the key is converted to a #GQuark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the #GQuark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optional data: object

      data to associate with that key

    Returns void

  • Defines the #GMainContext which will still process events while a potentially blocking operation is performed using cnc. If cnc is %NULL, then this function applies to all the connections, except the ones for which a different context has been defined (be it user defined connections or internal connections used in other objects). On the other hand, if cnc is not %NULL, then the setting only applied to cnc.

    For exemple if there is a GUI which needs to continue to handle events, then you can use this function to pass the default #GMainContext used for the UI refreshing, for example:

    If context is %NULL, then potentially blocking operation will actually block any event from being processed while the blocking operation is being performed.

    Parameters

    • thread: Thread

      the #GThread in which context will be used, or %NULL (for the current thread)

    • context: MainContext

      a #GMainContext, or %NULL

    Returns void

  • set_property(property_name: string, value?: any): void
  • Executes stmt.

    As stmt can, by design (and if not abused), contain only one SQL statement, the return object will either be: a #GdaDataSelect object (which is also a #GdaDataModel) if stmt is a SELECT statement (usually a GDA_SQL_STATEMENT_SELECT, see #GdaSqlStatementType) containing the results of the SELECT. The resulting data model is by default read only, but modifications can be enabled, see the #GdaDataSelect's documentation for more information. a #GdaSet for any other SQL statement which correctly executed. In this case (if the provider supports it), then the #GdaSet may contain value holders named: a (gint) #GdaHolder named "IMPACTED_ROWS" a (GObject) #GdaHolder named "EVENT" which contains a #GdaConnectionEvent

    If last_insert_row is not %NULL and stmt is an INSERT statement, then it will contain a new #GdaSet object composed of value holders named "+<column number>" starting at column 0 which contain the actual inserted values. For example if a table is composed of an 'id' column which is auto incremented and a 'name' column then the execution of a "INSERT INTO mytable (name) VALUES ('joe')" query will return a #GdaSet with two holders: one with the '+0' ID which may for example contain 1 (note that its "name" property should be "id") one with the '+1' ID which will contain 'joe' (note that its "name" property should be "name") Note that the value pointer by last_insert_row may be %NULL after the function call if either the database provider does not support it, or if the last interted row could not be determined (for example with SQLite if the table in which the data is inserted has the WITHOUT ROWID optimization).

    This method may fail with a %GDA_SERVER_PROVIDER_ERROR domain error (see the #GdaServerProviderError error codes).

    Note1: If stmt is a SELECT statement which has some parameters and if params is %NULL, then the statement can't be executed and this method will return %NULL.

    Note2: If stmt is a SELECT statement which has some parameters and if params is not %NULL but contains some invalid parameters, then the statement can't be executed and this method will return %NULL, unless the model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag.

    Note3: If stmt is a SELECT statement which has some parameters and if params is not %NULL but contains some invalid parameters and if model_usage has the GDA_STATEMENT_MODEL_ALLOW_NOPARAM flag, then the returned data model will contain no row but will have all the correct columns (even though some of the columns might report as GDA_TYPE_NULL). In this case, if (after this method call) any of params' parameters change then the resulting data model will re-run itself, see the GdaDataSelect's

    auto-reset property for more information.

    Note4: if model_usage does not contain the GDA_STATEMENT_MODEL_RANDOM_ACCESS or GDA_STATEMENT_MODEL_CURSOR_FORWARD flags, then the default will be to return a random access data model

    Note5: If stmt is a SELECT statement which returns blob values (of type %GDA_TYPE_BLOB), then an implicit transaction will have been started by the database provider, and it's up to the caller to close the transaction (which will then be locked) once all the blob ressources have been liberated (when the returned data model is destroyed). See the section about

    Binary large objects (BLOBs) for more information.

    Also see the provider's limitations, and the

    Advanced GdaDataSelect usage sections.

    Parameters

    • stmt: Gda.Statement

      a #GdaStatement object

    • params: Gda.Set

      a #GdaSet object (which can be obtained using gda_statement_get_parameters()), or %NULL

    • model_usage: Gda.StatementModelUsage

      in the case where stmt is a SELECT statement, specifies how the returned data model will be used

    Returns [GObject.Object, Gda.Set]

  • Executes a non-selection statement on the given connection.

    This function returns the number of rows affected by the execution of stmt, or -1 if an error occurred, or -2 if the connection's provider does not return the number of rows affected.

    This function is just a convenience function around the gda_connection_statement_execute() function. See the documentation of the gda_connection_statement_execute() for information about the params list of parameters.

    See gda_connection_statement_execute() form more information about last_insert_row.

    Parameters

    • stmt: Gda.Statement

      a #GdaStatement object.

    • params: Gda.Set

      a #GdaSet object (which can be obtained using gda_statement_get_parameters()), or %NULL

    Returns [number, Gda.Set]

  • Executes a selection command on the given connection.

    This function returns a #GdaDataModel resulting from the SELECT statement, or %NULL if an error occurred.

    This function is just a convenience function around the gda_connection_statement_execute() function.

    See the documentation of the gda_connection_statement_execute() for information about the params list of parameters.

    Parameters

    • stmt: Gda.Statement

      a #GdaStatement object.

    • params: Gda.Set

      a #GdaSet object (which can be obtained using gda_statement_get_parameters()), or %NULL

    Returns Gda.DataModel

  • Executes a selection command on the given connection.

    This function returns a #GdaDataModel resulting from the SELECT statement, or %NULL if an error occurred.

    This function is just a convenience function around the gda_connection_statement_execute() function.

    See the documentation of the gda_connection_statement_execute() for information about the params list of parameters.

    Parameters

    • stmt: Gda.Statement

      a #GdaStatement object.

    • params: Gda.Set

      a #GdaSet object (which can be obtained using gda_statement_get_parameters()), or %NULL

    • model_usage: Gda.StatementModelUsage

      specifies how the returned data model will be used as a #GdaStatementModelUsage enum

    • col_types: GType<unknown>[]

      an array of GType to request each returned #GdaDataModel's column's GType, terminated with the G_TYPE_NONE value. Any value left to 0 will make the database provider determine the real GType. col_types can also be %NULL if no column type is specified.

    Returns Gda.DataModel

  • 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).

    This function is also useful to make sure stmt is fully understood by the database before actually executing it.

    Note however that it is also possible that gda_connection_statement_prepare() fails when gda_connection_statement_execute() does not fail (this will usually be the case with statements such as because database usually don't allow variables to be used in place of a table name).

    Parameters

    Returns boolean

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

    Parameters

    • stmt: Gda.Statement

      a #GdaStatement object

    • params: Gda.Set

      a #GdaSet object (which can be obtained using gda_statement_get_parameters()), or %NULL

    • flags: Gda.StatementSqlFlag

      SQL rendering flags, as #GdaStatementSqlFlag OR'ed values

    Returns [string, Gda.Holder[]]

  • steal_data(key?: string): object
  • Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

    Parameters

    • Optional key: string

      name of the key

    Returns object

  • steal_qdata(quark: number): object
  • This function gets back user data pointers stored via g_object_set_qdata() 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:

    void
    object_add_to_user_list (GObject *object,
    const gchar *new_string)
    {
    // the quark, naming the object data
    GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
    // retrieve the old string list
    GList *list = g_object_steal_qdata (object, quark_string_list);

    // prepend new string
    list = g_list_prepend (list, g_strdup (new_string));
    // this changed 'list', so we need to set it again
    g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
    }
    static void
    free_string_list (gpointer data)
    {
    GList *node, *list = data;

    for (node = list; node; node = node->next)
    g_free (node->data);
    g_list_free (list);
    }

    Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

    Parameters

    • quark: number

      A #GQuark, naming the user data pointer

    Returns object

  • thaw_notify(): void
  • Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

    Duplicate notifications for each property are squashed so that at most one #GObject::notify signal is emitted for each property, in the reverse order in which they have been queued.

    It is an error to call this function when the freeze count is zero.

    Returns void

  • trylock(): boolean
  • Tries to lock lockable. If it is already locked by another thread, then it immediately returns FALSE, otherwise it locks lockable.

    Note: unlike g_mutex_lock(), this method recursive, which means a thread can lock lockable several times (and has to unlock it as many times to actually unlock it).

    Returns boolean

  • unlock(): void
  • Unlocks lockable. This method should not be called if the current does not already holds a lock on lockable (having used gda_lockable_lock() or gda_lockable_trylock()).

    Returns void

  • unref(): void
  • Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

    If the pointer to the #GObject may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to %NULL rather than retain a dangling pointer to a potentially invalid #GObject instance. Use g_clear_object() for this.

    Returns void

  • 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:

    In order to keep the meta store's contents in a consistent state, the update process involves updating the contents of all the tables related to one where the contents change. For example the "_columns" table (which lists all the columns of a table) depends on the "_tables" table (which lists all the tables in a schema), so if a row is added, removed or modified in the "_tables", then the "_columns" table's contents needs to be updated as well regarding that row.

    If context is %NULL, then the update process will simply overwrite any data that was present in all the meta store's tables with new (up to date) data even if nothing has changed, without having to build the tables' dependency tree. This is the recommended way of proceeding when dealing with a meta store which might be outdated.

    On the other hand, if context is not %NULL, then a tree of the dependencies has to be built (depending on context) and only some parts of the meta store are updated following that dependencies tree. Specifying a context may be useful for example in the following situations: One knows that a database object has changed (for example a table created), and may use the context to request that only the information about that table be updated One is only interested in the list of views, and may request that only the information about views may be updated

    When context is not %NULL, and contains specified SQL identifiers (for example the "table_name" of the "_tables" table), then each SQL identifier has to match the convention the #GdaMetaStore has adopted regarding case sensitivity, using gda_connection_quote_sql_identifier() or gda_meta_store_sql_identifier_quote().

    see the meta data section about SQL identifiers for more information, and the documentation about the gda_sql_identifier_quote() function which will be most useful.

    Note however that usually more information will be updated than strictly requested by the context argument.

    For more information, see the Database structure section, and the Update the meta data about a table howto.

    Parameters

    • context: Gda.MetaContext

      description of which part of cnc's associated #GdaMetaStore should be updated, or %NULL

    Returns boolean

  • update_row_in_table_v(table: string, condition_column_name: string, condition_value: any, col_names: string[], values: any[]): boolean
  • col_names and values must have length (>= 1).

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

    The equivalent SQL command is: UPDATE <table> SET <column_name> = <new_value> [,...] WHERE <condition_column_name> = <condition_value>.

    Parameters

    • table: string

      the table's name with the row's values to be updated

    • condition_column_name: string

      the name of the column to used in the WHERE condition clause

    • condition_value: any

      the condition_column_type's GType

    • col_names: string[]

      a list of column names (as const gchar *)

    • values: any[]

      a list of values (as #GValue)

    Returns boolean

  • value_to_sql_string(from: any): string
  • Produces a fully quoted and escaped string from a GValue

    Parameters

    • from: any

      #GValue to convert from

    Returns string

  • vfunc_closed(): void
  • vfunc_constructed(): void
  • vfunc_dispatch_properties_changed(n_pspecs: number, pspecs: ParamSpec): void
  • vfunc_dispose(): void
  • vfunc_dsn_changed(): void
  • vfunc_finalize(): void
  • vfunc_get_property(property_id: number, value?: any, pspec?: ParamSpec): void
  • vfunc_lock(): void
  • Locks lockable. If it is already locked by another thread, the current thread will block until it is unlocked by the other thread.

    Note: unlike g_mutex_lock(), this method recursive, which means a thread can lock lockable several times (and has to unlock it as many times to actually unlock it).

    virtual

    Returns void

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

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    virtual

    Parameters

    Returns void

  • vfunc_opened(): void
  • vfunc_set_property(property_id: number, value?: any, pspec?: ParamSpec): void
  • vfunc_transaction_status_changed(): void
  • vfunc_trylock(): boolean
  • Tries to lock lockable. If it is already locked by another thread, then it immediately returns FALSE, otherwise it locks lockable.

    Note: unlike g_mutex_lock(), this method recursive, which means a thread can lock lockable several times (and has to unlock it as many times to actually unlock it).

    virtual

    Returns boolean

  • vfunc_unlock(): void
  • Unlocks lockable. This method should not be called if the current does not already holds a lock on lockable (having used gda_lockable_lock() or gda_lockable_trylock()).

    virtual

    Returns void

  • watch_closure(closure: TClosure<any, any>): void
  • 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 g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_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.

    Parameters

    • closure: TClosure<any, any>

      #GClosure to watch

    Returns void

  • compat_control(what: number, data: object): number
  • error_quark(): number
  • Find the #GParamSpec with the given name for an interface. Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().

    Parameters

    • g_iface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface

    • property_name: string

      name of a property to look up.

    Returns ParamSpec

  • Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created #GParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.

    This function is meant to be called from the interface's default vtable initialization function (the class_init member of #GTypeInfo.) It must not be called after after class_init has been called for any object types implementing this interface.

    If pspec is a floating reference, it will be consumed.

    Parameters

    • g_iface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface.

    • pspec: ParamSpec

      the #GParamSpec for the new property

    Returns void

  • Lists the properties of an interface.Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().

    Parameters

    • g_iface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface

    Returns ParamSpec[]

  • This function creates a new connection, using a pre-defined data source (DSN), see gda_config_define_dsn() 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_new_from_string() instead of this method.

    The auth_string can contain the authentication information for the server to accept the connection. It is a string containing semi-colon seperated named value, usually like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each name and value must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

    If auth_string is given, it wil be used, otherwise auth_string of #GdaDsnInfo will be used.

    The actual named parameters required depend on the provider being used, and that list is available as the auth_params member of the #GdaProviderInfo structure for each installed provider (use gda_config_get_provider_info() to get it). Also one can use the "gda-sql-6.0 -L" command to list the possible named parameters.

    This method may fail with a GDA_CONNECTION_ERROR domain error (see the #GdaConnectionError error codes) or a %GDA_CONFIG_ERROR domain error (see the #GdaConfigError error codes).

    The returned connection is not yet opened, you need to call gda_connection_open() or gda_connection_open_async().

    Parameters

    • dsn: Gda.DsnInfo

      data source name.

    • auth_string: string

      authentication string, or %NULL

    • options: Gda.ConnectionOptions

      options for the connection (see #GdaConnectionOptions).

    Returns Gda.Connection

  • This function creates a new function, using a pre-defined data source (DSN) name, see gda_config_define_dsn() 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_new_from_string() instead of this method.

    The dsn string must have the following format: "[<username>[:<password>]]<DSN>" (if <username> and/or <password> are provided, and auth_string is %NULL, then these username and passwords will be used). Note that if provided, <username> and <password> must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

    The auth_string can contain the authentication information for the server to accept the connection. It is a string containing semi-colon separated named value, usually like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each name and value must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

    The actual named parameters required depend on the provider being used, and that list is available as the auth_params member of the #GdaProviderInfo structure for each installed provider (use gda_config_get_provider_info() to get it). Also one can use the "gda-sql-6.0 -L" command to list the possible named parameters.

    This method may fail with a GDA_CONNECTION_ERROR domain error (see the #GdaConnectionError error codes) or a %GDA_CONFIG_ERROR domain error (see the #GdaConfigError error codes).

    The returned connection is not yet opened, you need to call gda_connection_open() or gda_connection_open_async().

    Parameters

    • dsn_name: string

      data source name.

    • auth_string: string

      authentication string, or %NULL

    • options: Gda.ConnectionOptions

      options for the connection (see #GdaConnectionOptions).

    Returns Gda.Connection

  • 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_rfc1738_encode() for more information.

    The possible keys depend on the provider, the "gda-sql-6.0 -L" command can be used to list the actual keys for each installed database provider.

    For example the connection string to open an SQLite connection to a database file named "my_data.db" in the current directory would be "DB_DIR=.;DB_NAME=my_data".

    The cnc_string string must have the following format: "[<provider>://][<username>[:<password>]]<connection_params>" (if <username> and/or <password> are provided, and auth_string is %NULL, then these username and passwords will be used, and if <provider> is provided and provider_name is %NULL then this provider will be used). Note that if provided, <username>, <password> and <provider> must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

    The auth_string must contain the authentication information for the server to accept the connection. It is a string containing semi-colon seperated named values, usually like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each name and value must be encoded as per RFC 1738, see gda_rfc1738_encode() for more information.

    The actual named parameters required depend on the provider being used, and that list is available as the auth_params member of the #GdaProviderInfo structure for each installed provider (use gda_config_get_provider_info() to get it). Similarly to the format of the connection string, use the "gda-sql-6.0 -L" command to list the possible named parameters.

    Additionally, it is possible to have the connection string respect the "<provider_name>://<real cnc string>" format, in which case the provider name and the real connection string will be extracted from that string (note that if provider_name is not %NULL then it will still be used as the provider ID).\

    This method may fail with a GDA_CONNECTION_ERROR domain error (see the #GdaConnectionError error codes) or a %GDA_CONFIG_ERROR domain error (see the #GdaConfigError error codes).

    The returned connection is not yet opened, you need to call gda_connection_open() or gda_connection_open_async().

    Parameters

    • provider_name: string

      provider ID to connect to, or %NULL

    • cnc_string: string

      connection string.

    • auth_string: string

      authentication string, or %NULL

    • options: Gda.ConnectionOptions

      options for the connection (see #GdaConnectionOptions).

    Returns Gda.Connection

  • Creates a new instance of a #GObject subtype and sets its properties.

    Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values.

    Parameters

    • object_type: GType<unknown>

      the type id of the #GObject subtype to instantiate

    • parameters: GObject.Parameter[]

      an array of #GParameter

    Returns GObject.Object

  • This function creates a connection and opens it, using a DSN. If opening fails, then no connection is created. See gda_connection_new_from_dsn() for more information.

    Parameters

    • dsn: Gda.DsnInfo

      data sourcename.

    • auth_string: string

      authentication string, or %NULL

    • options: Gda.ConnectionOptions

      options for the connection (see #GdaConnectionOptions).

    Returns Gda.Connection

  • This function creates a connection and opens it, using a DSN name. If opening fails, then no connection is created. The named DSN should be available. See gda_connection_new_from_dsn_name() for more information.

    Parameters

    • dsn_name: string

      data source name.

    • auth_string: string

      authentication string, or %NULL

    • options: Gda.ConnectionOptions

      options for the connection (see #GdaConnectionOptions).

    Returns Gda.Connection

  • This function creates a connection and opens it, using a connection string. If opening fails, then no connection is created. See gda_connection_new_from_string() for more information.

    Parameters

    • provider_name: string

      provider ID to connect to, or %NULL

    • cnc_string: string

      connection string.

    • auth_string: string

      authentication string, or %NULL

    • options: Gda.ConnectionOptions

      options for the connection (see #GdaConnectionOptions).

    Returns Gda.Connection

  • open_sqlite(directory: string, filename: string, auto_unlink: boolean): Gda.Connection
  • 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.

    Parameters

    • directory: string

      the directory the database file will be in, or %NULL for the default TMP directory

    • filename: string

      the database file name

    • auto_unlink: boolean

      if %TRUE, then the database file will be removed afterwards

    Returns Gda.Connection

  • string_split(string: string): [string, string, string, string]
  • 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.

    For example all the following connection strings:

    will return the following new strings (double quotes added here to delimit strings):

    Parameters

    • string: string

      a string in the "[<provider>://][<username>[:<password>]]<connection_params>" form

    Returns [string, string, string, string]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method