ODBCConfig

(class from pyomo.dataportal.plugins.db_table)

class pyomo.dataportal.plugins.db_table.ODBCConfig(filename=None, data=None)[source]

Bases: object

Encapsulates an ODBC configuration file, usually odbc.ini or .odbc.ini, as specified by IBM. ODBC config data can be loaded either from a file or a string containing the relevant formatted data. Calling load() after initialization will update existing information in the config object with the new information.

__init__(filename=None, data=None)[source]

Create a new ODBC config instance, loading data from the given file and/or data string. Once initialized, the new config will contain the data represented in both arguments, if any. Data specified as a string argument will override that in the file.

Methods

__init__([filename, data])

Create a new ODBC config instance, loading data from the given file and/or data string.

add_source(name, driver)

Add an ODBC data source to the configuration.

add_source_spec(name, spec)

Add an ODBC data source specification to the configuration.

del_source(name)

Remove an ODBC data source from the configuration.

del_source_spec(name)

Remove an ODBC data source specification from the configuration.

load([filename, data])

Load data from the given file and/or data string.

odbc_repr()

Get the full, odbc.ini-style representation of this ODBC configuration.

set_odbc_info(key, value)

Set an option for the ODBC handling specified in the configuration.

write(filename)

Write the current ODBC configuration to the given file.

Member Documentation

add_source(name, driver)[source]

Add an ODBC data source to the configuration. A data source consists of a unique source name and a driver string, which specifies how the source will be loaded. If a source name is not unique, it will replace the existing source of the same name. A source is required in order to have a source specification.

add_source_spec(name, spec)[source]

Add an ODBC data source specification to the configuration. A source specification consists of a unique name and a key-value mapping (i.e. dictionary) of options. In order to add a source specification, a data source with a matching name must exist in the configuration.

del_source(name)[source]

Remove an ODBC data source from the configuration. If any source specifications are based on this source, they will be removed as well.

del_source_spec(name)[source]

Remove an ODBC data source specification from the configuration.

load(filename=None, data=None)[source]

Load data from the given file and/or data string. If both are given, data contained in the string will override that in the file. If this config object already contains data, the new information loaded will update the old, replacing where keys are the same.

odbc_repr()[source]

Get the full, odbc.ini-style representation of this ODBC configuration.

set_odbc_info(key, value)[source]

Set an option for the ODBC handling specified in the configuration. An option consists of a key-value pair. Specifying an existing key will update the current value.

write(filename)[source]

Write the current ODBC configuration to the given file. Depends on the odbc_repr() function for a string representation of the stored ODBC config information.