Connection
Object Hierarchy:
Description:
Namespace: Gda
Package: libgda-6.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 MetaStore meta_store { owned get; set; }
- public ServerProvider provider { owned get; set; }
Static methods:
- public static Quark error_quark ()
- public static unowned Worker internal_get_worker (ServerProviderConnectionData? data)
Retreive a pointer to the Worker used internally by the connection.
- public static Connection open_from_dsn (DsnInfo dsn, string? auth_string, ConnectionOptions options) throws Error
This function creates a connection and opens it, using a DSN.
- public static Connection open_from_dsn_name (string dsn_name, string? auth_string, ConnectionOptions options) throws Error
This function creates a connection and opens it, using a DSN name.
- public static Connection open_from_string (string? provider_name, string cnc_string, string? auth_string, ConnectionOptions options) throws Error
This function creates a connection and opens it, using 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, out string out_cnc_params, out string out_provider, out string out_username, out string out_password)
Extract the provider, connection parameters, username and password from
string
.
Creation methods:
- protected Connection ()
- public Connection.from_dsn (DsnInfo dsn, string? auth_string, ConnectionOptions options) throws Error
This function creates a new connection, using a pre-defined data source (DSN ), see define_dsn for more information about how to define a DSN.
- public Connection.from_dsn_name (string dsn_name, string? auth_string, ConnectionOptions options) throws Error
This function creates a new function, using a pre-defined data source (DSN) name, see define_dsn for more information about how to define a DSN.
- public Connection.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.
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 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 bool close () throws Error
Closes the connection to the underlying data source.
- public bool commit_transaction (string? name) throws Error
Commits the given transaction to the backend database.
- public DbCatalog create_db_catalog ()
A convenient method to create a new DbCatalog instance and set the current this as a property.
- 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 MainContext get_main_context (Thread? thread)
Get the MainContext used while a potentially blocking operation is performed using
nc
, see set_main_context. - public unowned MetaStore get_meta_store ()
Get or initializes the MetaStore associated to this
- public DataModel get_meta_store_data_v (ConnectionMetaType meta_type, List<Holder> filters) throws Error
see
gda_connection_get_meta_store_data
- 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 ConnectionStatus get_status ()
Get the current status of this.
- public unowned TransactionStatus get_transaction_status ()
Get the status of this regarding transactions.
- 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 void internal_change_transaction_state (TransactionStatusState newstate)
Internal function to be called by database providers to force a transaction status change.
- public ServerProviderConnectionData? internal_get_provider_data_error () throws Error
Get the opaque pointer previously set using internal_set_provider_data.
- public void internal_reset_transaction_status ()
Internal function to be called by database providers to reset the transaction status.
- public void internal_savepoint_added (string? parent_trans, string svp_name)
Internal functions to be called by database providers when a savepoint has been added to keep track of the transaction status of the connection
- public void internal_savepoint_removed (string? svp_name)
Internal functions to be called by database providers when a savepoint has been removed to keep track of the transaction status of the connection
- public void internal_savepoint_rolledback (string? svp_name)
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
- public void internal_set_provider_data (ServerProviderConnectionData data, DestroyNotify destroy_func)
Note: calling this function more than once will not make it call
destroy_func
on any previously set opaquedata
, you'll have to do it yourself. - public void internal_statement_executed (Statement stmt, Set? @params, ConnectionEvent error)
Internal functions to be called by database providers when a statement has been executed to keep track of the transaction status of the connection
- public void internal_transaction_committed (string? trans_name)
Internal functions to be called by database providers when a transaction has been committed to keep track of the transaction status of the connection
- public void internal_transaction_rolledback (string? trans_name)
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
- public void internal_transaction_started (string? parent_trans, string trans_name, TransactionIsolation isol_level)
Internal functions to be called by database providers when a transaction has been started to keep track of the transaction status of the connection.
- public bool is_opened ()
Checks whether a connection is open or not.
- public bool open () throws Error
Tries to open the connection.
- public uint open_async (ConnectionOpenFunc callback) throws Error
This function requests that the connection be opened.
- public string? operation_get_sql_identifier_at_path (ServerOperation op, string path) throws Error
This method is similar to
gda_server_operation_get_value_at
, but for SQL identifiers: a new string is returned instead of a Value. - public Statement parse_sql_string (string sql, out Set? @params = null) 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 ServerOperation? prepare_operation_create_table (string table_name, List<ServerOperationCreateTableArg> arguments) throws Error
Add more arguments if the flag needs them:
- public ServerOperation? prepare_operation_drop_table (string table_name) throws Error
This is just a convenient function to create a ServerOperation to drop a table in an opened connection.
- 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 void set_main_context (Thread? thread, MainContext? context)
Defines the MainContext which will still process events while a potentially blocking operation is performed using this .
- public Object statement_execute (Statement stmt, Set? @params, StatementModelUsage model_usage, out Set? last_insert_row = null) throws Error
Executes
stmt
. - public int statement_execute_non_select (Statement stmt, Set? @params = null, out Set? last_insert_row = null) throws Error
Executes a non-selection statement on the given connection.
- public DataModel statement_execute_select (Statement stmt, Set? @params = null) 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 = null) throws 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_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 closed ()
Gets emitted when the connection to the database has been 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 opened ()
Gets emitted when the connection has been opened to the database
- public virtual signal void status_changed (ConnectionStatus status)
Gets emitted when the
cnc
's status has changed (usually when a the connection is being used to execute a statement) - 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