Gda.DataHandler

g GObject.GInterface GObject.GInterface Gda.DataHandler Gda.DataHandler GObject.GInterface->Gda.DataHandler

Implementations:

Gda.HandlerBin, Gda.HandlerBoolean, Gda.HandlerNumerical, Gda.HandlerString, Gda.HandlerTime, Gda.HandlerType

Methods

class

get_default (for_type)

accepts_g_type (type)

get_descr ()

get_sane_init_value (type)

get_sql_from_value (value)

get_str_from_value (value)

get_value_from_sql (sql, type)

get_value_from_str (str, type)

Virtual Methods

do_accepts_g_type (type)

do_get_descr ()

do_get_sane_init_value (type)

do_get_sql_from_value (value)

do_get_str_from_value (value)

do_get_value_from_sql (sql, type)

do_get_value_from_str (str, type)

Properties

None

Signals

None

Fields

None

Class Details

class Gda.DataHandler
Bases:

GObject.GInterface

Structure:

Gda.DataHandlerIface

classmethod get_default(for_type)
Parameters:

for_type (GObject.GType) – a GObject.GType type

Returns:

a Gda.DataHandler which must not be modified or destroyed.

Return type:

Gda.DataHandler

Obtain a pointer to a Gda.DataHandler which can manage GObject.Value values of type for_type. The returned data handler will be adapted to use the current locale information (for example dates will be formatted taking into account the locale).

The returned pointer is None if there is no default data handler available for the for_type data type

New in version 4.2.3.

accepts_g_type(type)
Parameters:

type (GObject.GType) – a GObject.GType

Returns:

True if the gda type can be handled

Return type:

bool

Checks wether the Gda.DataHandler is able to handle the gda type given as argument.

get_descr()
Returns:

the description

Return type:

str

Get a short description of the Gda.DataHandler

get_sane_init_value(type)
Parameters:

type (GObject.GType) – a GObject.GType

Returns:

the new GObject.Value, or None if no such value can be created.

Return type:

GObject.Value or None

Creates a new GObject.Value which holds a sane initial value to be used if no value is specifically provided. For example for a simple string, this would return a new value containing the “” string.

get_sql_from_value(value)
Parameters:

value (GObject.Value or None) – the value to be converted to a string, or None

Returns:

the new string, or None if an error occurred

Return type:

str

Creates a new string which is an SQL representation of the given value, the returned string can be used directly in an SQL statement. For example if value is a GObject.TYPE_STRING, then the returned string will be correctly quoted. Note however that it is a better practice to use variables in statements instead of value literals, see the ‘GdaSqlParser [GdaSqlParser.description]’ for more information.

If the value is None or is of type GDA_TYPE_NULL, or is a GObject.TYPE_STRING and GObject.Value.get_string() returns None, the returned string is “None".

get_str_from_value(value)
Parameters:

value (GObject.Value or None) – the value to be converted to a string, or None

Returns:

the new string, or None if an error occurred

Return type:

str

Creates a new string which is a “user friendly” representation of the given value (in the user’s locale, specially for the dates). If the value is None or is of type GDA_TYPE_NULL, the returned string is a copy of “” (empty string).

Note: the returned value will be in the current locale representation.

get_value_from_sql(sql, type)
Parameters:
Returns:

the new GObject.Value or None on error

Return type:

GObject.Value

Creates a new GObject.Value which represents the SQL value given as argument. This is the opposite of the function Gda.DataHandler.get_sql_from_value(). The type argument is used to determine the real data type requested for the returned value.

If the sql string is None, then the returned GObject.Value is of type GDA_TYPE_NULL; if the sql string does not correspond to a valid SQL string for the requested type, then the None is returned.

get_value_from_str(str, type)
Parameters:
Returns:

the new GObject.Value or None on error

Return type:

GObject.Value

Creates a new GObject.Value which represents the str value given as argument. This is the opposite of the function Gda.DataHandler.get_str_from_value(). The type argument is used to determine the real data type requested for the returned value.

If the str string is None, then the returned GObject.Value is of type GDA_TYPE_NULL; if the str string does not correspond to a valid string for the requested type, then None is returned.

Note: the str string must be in the current locale representation

do_accepts_g_type(type) virtual
Parameters:

type (GObject.GType) – a GObject.GType

Returns:

True if the gda type can be handled

Return type:

bool

Checks wether the Gda.DataHandler is able to handle the gda type given as argument.

do_get_descr() virtual
Returns:

the description

Return type:

str

Get a short description of the Gda.DataHandler

do_get_sane_init_value(type) virtual
Parameters:

type (GObject.GType) – a GObject.GType

Returns:

the new GObject.Value, or None if no such value can be created.

Return type:

GObject.Value or None

Creates a new GObject.Value which holds a sane initial value to be used if no value is specifically provided. For example for a simple string, this would return a new value containing the “” string.

do_get_sql_from_value(value) virtual
Parameters:

value (GObject.Value or None) – the value to be converted to a string, or None

Returns:

the new string, or None if an error occurred

Return type:

str

Creates a new string which is an SQL representation of the given value, the returned string can be used directly in an SQL statement. For example if value is a GObject.TYPE_STRING, then the returned string will be correctly quoted. Note however that it is a better practice to use variables in statements instead of value literals, see the ‘GdaSqlParser [GdaSqlParser.description]’ for more information.

If the value is None or is of type GDA_TYPE_NULL, or is a GObject.TYPE_STRING and GObject.Value.get_string() returns None, the returned string is “None".

do_get_str_from_value(value) virtual
Parameters:

value (GObject.Value or None) – the value to be converted to a string, or None

Returns:

the new string, or None if an error occurred

Return type:

str

Creates a new string which is a “user friendly” representation of the given value (in the user’s locale, specially for the dates). If the value is None or is of type GDA_TYPE_NULL, the returned string is a copy of “” (empty string).

Note: the returned value will be in the current locale representation.

do_get_value_from_sql(sql, type) virtual
Parameters:
Returns:

the new GObject.Value or None on error

Return type:

GObject.Value

Creates a new GObject.Value which represents the SQL value given as argument. This is the opposite of the function Gda.DataHandler.get_sql_from_value(). The type argument is used to determine the real data type requested for the returned value.

If the sql string is None, then the returned GObject.Value is of type GDA_TYPE_NULL; if the sql string does not correspond to a valid SQL string for the requested type, then the None is returned.

do_get_value_from_str(str, type) virtual
Parameters:
Returns:

the new GObject.Value or None on error

Return type:

GObject.Value

Creates a new GObject.Value which represents the str value given as argument. This is the opposite of the function Gda.DataHandler.get_str_from_value(). The type argument is used to determine the real data type requested for the returned value.

If the str string is None, then the returned GObject.Value is of type GDA_TYPE_NULL; if the str string does not correspond to a valid string for the requested type, then None is returned.

Note: the str string must be in the current locale representation