Gda.ServerProvider

g GObject.Object GObject.Object Gda.ServerProvider Gda.ServerProvider GObject.Object->Gda.ServerProvider

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

error_quark ()

class

load_file_contents (inst_dir, data_dir, filename)

create_operation (cnc, type, options)

create_parser (cnc)

escape_string (cnc, str)

find_file (inst_dir, filename)

get_data_handler_dbms (cnc, for_type)

get_data_handler_default (cnc, type, dbms_type)

get_data_handler_g_type (cnc, for_type)

get_default_dbms_type (cnc, type)

get_name ()

get_server_version (cnc)

get_version ()

handler_declare (dh, cnc, g_type, dbms_type)

handler_find (cnc, g_type, dbms_type)

internal_get_parser ()

perform_operation (cnc, op)

perform_operation_default (cnc, op)

render_operation (cnc, op)

string_to_value (cnc, string, preferred_type, dbms_type)

supports_feature (cnc, feature)

supports_operation (cnc, type, options)

unescape_string (cnc, str)

value_to_sql_string (cnc, from_)

Virtual Methods

Inherited:

GObject.Object (7)

do_add_savepoint (cnc, name)

do_begin_transaction (cnc, name, level)

do_cancel (cnc, task_id)

do_close_connection (cnc)

do_commit_transaction (cnc, name)

do_create_operation (cnc, type, options)

do_create_parser (cnc)

do_delete_savepoint (cnc, name)

do_escape_string (cnc, str)

do_get_database (cnc)

do_get_def_dbms_type (cnc, g_type)

do_get_name ()

do_get_server_version (cnc)

do_get_version ()

do_handle_async (cnc)

do_identifier_quote (cnc, id, for_meta_store, force_quotes)

do_is_busy (cnc)

do_render_operation (cnc, op)

do_rollback_savepoint (cnc, name)

do_rollback_transaction (cnc, name)

do_statement_prepare (cnc, stmt)

do_supports_feature (cnc, feature)

do_supports_operation (cnc, type, options)

do_unescape_string (cnc, str)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

object

GObject.Object

r

priv

Gda.ServerProviderPrivate

r

Class Details

class Gda.ServerProvider(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gda.ServerProviderClass

classmethod error_quark()
Return type:

int

classmethod load_file_contents(inst_dir, data_dir, filename)
Parameters:
  • inst_dir (str) – directory where the database provider has been installed

  • data_dir (str) – DATA directory to look for ($prefix/share)

  • filename (str) – name of the file to load

Returns:

a new string containing filename's contents, or None if not found or if an error occurred

Return type:

str

Loads and returns the contents of filename, which is searched in several places This function should only be used by database provider’s implementations

create_operation(cnc, type, options)
Parameters:
Raises:

GLib.Error

Returns:

a new Gda.ServerOperation object, or None in the provider does not support the type type of operation or if an error occurred

Return type:

Gda.ServerOperation or None

Creates a new Gda.ServerOperation object which can be modified in order to perform the type type of action. The options can contain:

  • named values which ID is a path in the resulting Gda.ServerOperation object, to initialize some value

  • named values which may change the contents of the Gda.ServerOperation, see ‘this section [gda-server-op-information-std]’ for more information

create_parser(cnc)
Parameters:

cnc (Gda.Connection or None) – a Gda.Connection, or None

Returns:

a new Gda.SqlParser object, or None.

Return type:

Gda.SqlParser

Creates a new Gda.SqlParser object which is adapted to self (and possibly depending on cnc for the actual database version).

If prov does not have its own parser, then None is returned, and a general SQL parser can be obtained using Gda.SqlParser.new().

escape_string(cnc, str)
Parameters:
Returns:

a new string suitable to use in SQL statements

Return type:

str

Escapes str for use within an SQL command (to avoid SQL injection attacks). Note that the returned value still needs to be enclosed in single quotes before being used in an SQL statement.

find_file(inst_dir, filename)
Parameters:
  • inst_dir (str) – directory where self is installed

  • filename (str) – name of the file to find

Returns:

the complete path to filename, or None if not found

Return type:

str

Finds the location of a filename. This function should only be used by database provider’s implementations

get_data_handler_dbms(cnc, for_type)
Parameters:
Returns:

a Gda.DataHandler, or None if the provider does not know about the for_type type

Return type:

Gda.DataHandler

Find a Gda.DataHandler object to manipulate data of type for_type.

Note: this function is currently very poorly implemented by database providers.

get_data_handler_default(cnc, type, dbms_type)
Parameters:
Returns:

a Gda.DataHandler, or None

Return type:

Gda.DataHandler

Provides the implementation when the default Libgda’s data handlers must be used

Deprecated since version 5.2: use gda_server_provider_handler_use_default() instead

get_data_handler_g_type(cnc, for_type)
Parameters:
Returns:

a Gda.DataHandler, or None if the provider does not support the requested for_type data type

Return type:

Gda.DataHandler

Find a Gda.DataHandler object to manipulate data of type for_type. The returned object must not be modified.

get_default_dbms_type(cnc, type)
Parameters:
Returns:

the name of the DBMS type, or None

Return type:

str or None

Get the name of the most common data type which has type type.

The returned value may be None either if the provider does not implement that method, or if there is no DBMS data type which could contain data of the g_type type (for example None may be returned if a DBMS has integers only up to 4 bytes and a GObject.TYPE_INT64 is requested).

get_name()
Returns:

a string containing the provider’s name

Return type:

str

Get the name (identifier) of the provider

get_server_version(cnc)
Parameters:

cnc (Gda.Connection) – a Gda.Connection object

Returns:

a (read only) string, or None if an error occurred

Return type:

str

Get the version of the database to which the connection is opened.

get_version()
Returns:

a string containing the version identification.

Return type:

str

Get the version of the provider.

handler_declare(dh, cnc, g_type, dbms_type)
Parameters:
handler_find(cnc, g_type, dbms_type)
Parameters:
Returns:

the requested Gda.DataHandler, or None if none found

Return type:

Gda.DataHandler

Reserved to database provider’s implementations: get the Gda.DataHandler associated to self for connection cnc. You probably want to use Gda.ServerProvider.get_data_handler_g_type().

internal_get_parser()
Returns:

a Gda.SqlParser

Return type:

Gda.SqlParser

This is a factory method to get a unique instance of a Gda.SqlParser object for each Gda.ServerProvider object Don’t unref it.

perform_operation(cnc, op)
Parameters:
Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Performs the operation described by op. Note that op is not destroyed by this method and can be reused.

perform_operation_default(cnc, op)
Parameters:
Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Performs the operation described by op, using the SQL from the rendering of the operation

render_operation(cnc, op)
Parameters:
Raises:

GLib.Error

Returns:

a new string, or None if an error occurred or operation cannot be rendered as SQL.

Return type:

str or None

Creates an SQL statement (possibly using some specific extensions of the DBMS) corresponding to the op operation. Note that the returned string may actually contain more than one SQL statement.

This function’s purpose is mainly informative to get the actual SQL code which would be executed to perform the operation; to actually perform the operation, use Gda.ServerProvider.perform_operation().

string_to_value(cnc, string, preferred_type, dbms_type)
Parameters:
Returns:

a new GObject.Value, or None

Return type:

GObject.Value

Use self to create a new GObject.Value from a single string representation.

The preferred_type can optionally ask self to return a GObject.Value of the requested type (but if such a value can’t be created from string, then None is returned); pass GObject.TYPE_INVALID if any returned type is acceptable.

The returned value is either a new GObject.Value or None in the following cases:

  • string cannot be converted to preferred_type type

  • the provider does not handle preferred_type

  • the provider could not make a GObject.Value from string

If dbms_type is not None, then if will contain a constant string representing the database type used for the conversion if the conversion was successfull, or None otherwise.

supports_feature(cnc, feature)
Parameters:
Returns:

True if feature is supported

Return type:

bool

Tests if a feature is supported

supports_operation(cnc, type, options)
Parameters:
Returns:

True if the operation is supported

Return type:

bool

Tells if self supports the type of operation on the cnc connection, using the (optional) options parameters.

unescape_string(cnc, str)
Parameters:
Returns:

a new string

Return type:

str

Unescapes str for use within an SQL command. This is the exact opposite of Gda.ServerProvider.escape_string().

value_to_sql_string(cnc, from_)
Parameters:
Returns:

escaped and quoted value or None if not supported.

Return type:

str

Produces a fully quoted and escaped string from a GObject.Value

do_add_savepoint(cnc, name) virtual
Parameters:
Return type:

bool

do_begin_transaction(cnc, name, level) virtual
Parameters:
Return type:

bool

do_cancel(cnc, task_id) virtual
Parameters:
Return type:

bool

do_close_connection(cnc) virtual
Parameters:

cnc (Gda.Connection) –

Return type:

bool

do_commit_transaction(cnc, name) virtual
Parameters:
Return type:

bool

do_create_operation(cnc, type, options) virtual
Parameters:
Returns:

a new Gda.ServerOperation object, or None in the provider does not support the type type of operation or if an error occurred

Return type:

Gda.ServerOperation or None

Creates a new Gda.ServerOperation object which can be modified in order to perform the type type of action. The options can contain:

  • named values which ID is a path in the resulting Gda.ServerOperation object, to initialize some value

  • named values which may change the contents of the Gda.ServerOperation, see ‘this section [gda-server-op-information-std]’ for more information

do_create_parser(cnc) virtual
Parameters:

cnc (Gda.Connection or None) – a Gda.Connection, or None

Returns:

a new Gda.SqlParser object, or None.

Return type:

Gda.SqlParser

Creates a new Gda.SqlParser object which is adapted to provider (and possibly depending on cnc for the actual database version).

If prov does not have its own parser, then None is returned, and a general SQL parser can be obtained using Gda.SqlParser.new().

do_delete_savepoint(cnc, name) virtual
Parameters:
Return type:

bool

do_escape_string(cnc, str) virtual
Parameters:
Returns:

a new string suitable to use in SQL statements

Return type:

str

Escapes str for use within an SQL command (to avoid SQL injection attacks). Note that the returned value still needs to be enclosed in single quotes before being used in an SQL statement.

do_get_database(cnc) virtual
Parameters:

cnc (Gda.Connection) –

Return type:

str

do_get_def_dbms_type(cnc, g_type) virtual
Parameters:
Return type:

str

do_get_name() virtual
Returns:

a string containing the provider’s name

Return type:

str

Get the name (identifier) of the provider

do_get_server_version(cnc) virtual
Parameters:

cnc (Gda.Connection) – a Gda.Connection object

Returns:

a (read only) string, or None if an error occurred

Return type:

str

Get the version of the database to which the connection is opened.

do_get_version() virtual
Returns:

a string containing the version identification.

Return type:

str

Get the version of the provider.

do_handle_async(cnc) virtual
Parameters:

cnc (Gda.Connection) –

Return type:

bool

do_identifier_quote(cnc, id, for_meta_store, force_quotes) virtual
Parameters:
Return type:

str

do_is_busy(cnc) virtual
Parameters:

cnc (Gda.Connection) –

Return type:

bool

do_render_operation(cnc, op) virtual
Parameters:
Returns:

a new string, or None if an error occurred or operation cannot be rendered as SQL.

Return type:

str or None

Creates an SQL statement (possibly using some specific extensions of the DBMS) corresponding to the op operation. Note that the returned string may actually contain more than one SQL statement.

This function’s purpose is mainly informative to get the actual SQL code which would be executed to perform the operation; to actually perform the operation, use Gda.ServerProvider.perform_operation().

do_rollback_savepoint(cnc, name) virtual
Parameters:
Return type:

bool

do_rollback_transaction(cnc, name) virtual
Parameters:
Return type:

bool

do_statement_prepare(cnc, stmt) virtual
Parameters:
Return type:

bool

do_supports_feature(cnc, feature) virtual
Parameters:
Returns:

True if feature is supported

Return type:

bool

Tests if a feature is supported

do_supports_operation(cnc, type, options) virtual
Parameters:
Returns:

True if the operation is supported

Return type:

bool

Tells if provider supports the type of operation on the cnc connection, using the (optional) options parameters.

do_unescape_string(cnc, str) virtual
Parameters:
Returns:

a new string

Return type:

str

Unescapes str for use within an SQL command. This is the exact opposite of Gda.ServerProvider.escape_string().