Connection
Object Hierarchy:
Description:
Namespace: Gda
Package: libgda-5.0
Content:
Properties:
- public string auth_string { owned get; set; }
- public string cnc_string { owned get; set; }
- public string dsn { owned get; set; }
- public int events_history_size { get; set; }
Defines the number of ConnectionEvent objects kept in memory which can be fetched using get_events.
- public uint execution_slowdown { get; set; }
Artificially slows down the execution of queries.
- public bool execution_timer { get; set; }
Computes execution times for each statement executed.
- public bool is_wrapper { get; set; }
This property, if set to
true
, specifies that the connection is not a real connection, but rather a Connection object which "proxies" all the calls to another connection which executes in a sub thread. - public MetaStore meta_store { owned get; set; }
- public bool monitor_wrapped_in_mainloop { get; set; }
Useful only when there is a mainloop and when the connection acts as a thread wrapper around another connection, it sets up a timeout to handle signals coming from the wrapped connection.
- public ServerProvider provider { owned get; set; }
- public void* thread_owner { get; set; }
Static methods:
- public static Quark error_quark ()
- public static Connection open_from_dsn (string dsn, string? auth_string, ConnectionOptions options) throws Error
This function is the way of opening database connections with libgda, using a pre-defined data source (DSN), see define_dsn for more information about how to define a DSN.
- public static Connection open_from_string (string? provider_name, string cnc_string, string? auth_string, ConnectionOptions options) throws Error
Opens a connection given a provider ID and a connection string.
- public static Connection open_sqlite (string? directory, string filename, bool auto_unlink)
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.
- public static void string_split (string string, string out_cnc_params, string out_provider, string out_username, string? out_password)
Extract the provider, connection parameters, username and password from
string
.
Creation methods:
- protected Connection ()
- public Connection.from_dsn (string dsn, string? auth_string, ConnectionOptions options) throws Error
This function is similar to open_from_dsn, except it does not actually open the connection, you have to open it using open.
- public Connection.from_string (string? provider_name, string cnc_string, string? auth_string, ConnectionOptions options) throws Error
This function is similar to open_from_string, except it does not actually open the connection, you have to open it using open.
Methods:
- public void add_event (owned ConnectionEvent event)
Adds an event to the given connection.
- public void add_prepared_statement (Statement gda_stmt, PStmt prepared_stmt)
Declares that
prepared_stmt
is a prepared statement object associated togda_stmt
within the connection (meaning the connection increments the reference counter ofprepared_stmt
). - public bool add_savepoint (string? name) throws Error
Adds a SAVEPOINT named
name
. - public bool async_cancel (uint task_id) throws Error
Requests that a task be cancelled.
- public Object async_fetch_result (uint task_id, out Set last_insert_row) throws Error
Use this method to obtain the result of the execution of a statement which has been executed asynchronously by calling async_statement_execute.
- public uint async_statement_execute (Statement stmt, Set? @params, StatementModelUsage model_usage, Type[]? col_types, bool need_last_insert_row) throws Error
This method is similar to statement_execute but is asynchronous as it method returns immediately with a task ID.
- public SList<Object> batch_execute (Batch batch, Set? @params, StatementModelUsage model_usage) throws Error
Executes all the statements contained in
batch
(in the order in which they were added tobatch
), and returns a list of Object objects, at most one Object for each statement; see statement_execute for details about the returned objects. - public bool begin_transaction (string? name, TransactionIsolation level) throws Error
Starts a transaction on the data source, identified by the
name
parameter. - public void clear_events_list ()
This function lets you clear the list of ConnectionEvent's of the given connection.
- public void close ()
Closes the connection to the underlying data source, but first emits the "conn-to-close" signal.
- public void close_no_warning ()
Closes the connection to the underlying data source, without emiting any warning signal.
- public bool commit_transaction (string? name) throws Error
Commits the given transaction to the backend database.
- public ServerOperation create_operation (ServerOperationType type, Set? options) throws Error
Creates a new ServerOperation object which can be modified in order to perform the type type of action.
- public SqlParser create_parser ()
Creates a new parser object able to parse the SQL dialect understood by this.
- public void del_prepared_statement (Statement gda_stmt)
Removes any prepared statement associated to
gda_stmt
in this: this undoes what add_prepared_statement does. - public bool delete_row_from_table (string table, string condition_column_name, Value condition_value) throws Error
This is a convenience function, which creates a DELETE statement and executes it using the values provided.
- public bool delete_savepoint (string? name) throws Error
Delete the SAVEPOINT named
name
when not used anymore. - public int execute_non_select_command (string sql) throws Error
This is a convenience function to execute a SQL command over the opened connection.
- public DataModel execute_select_command (string sql) throws Error
Execute a SQL SELECT command over an opened connection.
- public unowned string get_authentication ()
Gets the user name used to open this connection.
- public unowned string get_cnc_string ()
Gets the connection string used to open this connection.
- public bool get_date_format (out DateDMY out_first, out DateDMY out_second, out DateDMY out_third, out string out_sep) throws Error
This function allows you to determine the actual format for the date values.
- public unowned string get_dsn ()
- public unowned List<ConnectionEvent> get_events ()
Retrieves a list of the last errors occurred during the connection.
- public unowned MetaStore get_meta_store ()
Get or initializes the MetaStore associated to this
- public DataModel get_meta_store_data (ConnectionMetaType meta_type, Error error, int nb_filters, ...)
Retrieves data stored in this's associated MetaStore object.
- public DataModel get_meta_store_data_v (ConnectionMetaType meta_type, List<Holder> filters) throws Error
- public ConnectionOptions get_options ()
Gets the ConnectionOptions used to open this connection.
- public unowned PStmt get_prepared_statement (Statement gda_stmt)
Retrieves a pointer to an object representing a prepared statement for
gda_stmt
within this. - public unowned ServerProvider get_provider ()
Gets a pointer to the ServerProvider object used to access the database
- public unowned string get_provider_name ()
Gets the name (identifier) of the database provider used by this
- public unowned TransactionStatus get_transaction_status ()
Get the status of this regarding transactions.
- public bool insert_row_into_table (string table, Error error, ...)
This is a convenience function, which creates an INSERT statement and executes it using the values provided.
- public bool insert_row_into_table_v (string table, SList<string> col_names, SList<Value?> values) throws Error
col_names
andvalues
must have length (>= 1). - public bool is_opened ()
Checks whether a connection is open or not.
- public bool open () throws Error
Tries to open the connection.
- public Statement parse_sql_string (string sql, out Set @params) throws Error
This function helps to parse a SQL string which uses parameters and store them at
params
. - public bool perform_operation (ServerOperation op) throws Error
Performs the operation described by
op
(which should have been created using create_operation). - public ConnectionEvent point_available_event (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 add_event.
- public string quote_sql_identifier (string id)
Use this method to get a correctly quoted (if necessary) SQL identifier which can be used in SQL statements, from
id
. - public SList<Object> repetitive_statement_execute (RepetitiveStatement rstmt, StatementModelUsage model_usage, Type[]? col_types, bool stop_on_error) throws Error
Executes the statement upon which
rstmt
is built. - public bool rollback_savepoint (string? name) throws Error
Rollback all the modifications made after the SAVEPOINT named
name
. - public bool rollback_transaction (string? name) throws Error
Rollbacks the given transaction.
- public Object statement_execute (Statement stmt, Set? @params, StatementModelUsage model_usage, out Set last_insert_row) throws Error
Executes
stmt
. - public int statement_execute_non_select (Statement stmt, Set? @params, out Set last_insert_row) throws Error
Executes a non-selection statement on the given connection.
- public DataModel statement_execute_select (Statement stmt, Set? @params) throws Error
Executes a selection command on the given connection.
- public DataModel statement_execute_select_full (Statement stmt, Set? @params, StatementModelUsage model_usage, Type[]? col_types) throws Error
Executes a selection command on the given connection.
- public DataModel statement_execute_select_fullv (Statement stmt, Set? @params, StatementModelUsage model_usage, Error error, ...)
Executes a selection command on the given connection.
- public bool statement_prepare (Statement stmt) throws Error
Ask the database accessed through the this connection to prepare the usage of
stmt
. - public string statement_to_sql (Statement stmt, Set? @params, StatementSqlFlag flags, out SList<unowned Holder> params_used) throws Error
Renders
stmt
as an SQL statement, adapted to the SQL dialect used by this - public bool supports_feature (ConnectionFeature feature)
Asks the underlying provider for if a specific feature is supported.
- public bool update_meta_store (MetaContext? context) throws Error
Updates this's associated MetaStore.
- public bool update_row_in_table (string table, string condition_column_name, Value condition_value, Error error, ...)
This is a convenience function, which creates an UPDATE statement and executes it using the values provided.
- public bool update_row_in_table_v (string table, string condition_column_name, Value condition_value, SList<string> col_names, SList<Value?> values) throws Error
col_names
andvalues
must have length (>= 1). - public string value_to_sql_string (Value from)
Produces a fully quoted and escaped string from a GValue
Signals:
- public virtual signal void conn_closed ()
Gets emitted when the connection to the database has been closed
- public virtual signal void conn_opened ()
Gets emitted when the connection has been opened to the database
- public virtual signal void conn_to_close ()
Gets emitted when the connection to the database is about to be closed
- public virtual signal void dsn_changed ()
Gets emitted when the DSN used by
cnc
has been changed - public virtual signal void error (ConnectionEvent error)
Gets emitted whenever a connection event occurs.
- public virtual signal void transaction_status_changed ()
Gets emitted when the transaction status of
cnc
has changed (a transaction has been started, rolled back, a savepoint added,...)
Inherited Members:
All known members inherited from class GLib.Object