|
ensembl-hive
2.7.0
|
Inheritance diagram for Bio::EnsEMBL::DBSQL::DBConnection:Public Member Functions | |
| public Bio::EnsEMBL::DBSQL::DBConnection | new () |
| public void | connect () |
| public Undef | connected () |
| public | disconnect_count () |
| public | timeout () |
| public | query_count () |
| public Boolean | equals () |
| public String | driver () |
| public String | port () |
| public String | dbname () |
| public String | username () |
| public String | user () |
| public String | host () |
| public String | hostname () |
| public String | password () |
| public String | pass () |
| public Boolean | disconnect_when_inactive () |
| public Boolean | reconnect_when_lost () |
| public String | locator () |
| public DBI | db_handle () |
| public DBI | prepare () |
| public DBI | prepare_cached () |
| public void | reconnect () |
| public Result | do () |
| public Any | work_with_db_handle () |
| public void | prevent_disconnect () |
| public ArrayRef | quote_identifier () |
| public Boolean | disconnect_if_idle () |
| public SQLStatement | add_limit_clause () |
| public String | from_date_to_seconds () |
| public String | from_seconds_to_date () |
| public Bio::EnsEMBL::Utils::SqlHelper | sql_helper () |
| public Hash | to_hash () |
| protected | _driver_object () |
This class is a wrapper around DBIs datbase handle. It provides some additional functionality such as the ability to automatically disconnect when inactive and reconnect when needed. Generally this class will be used through one of the object adaptors or the Bio::EnsEMBL::Registry and will not be instantiated directly.
Definition at line 42 of file DBConnection.pm.
| protected Bio::EnsEMBL::DBSQL::DBConnection::_driver_object | ( | ) |
Code:
| public SQLStatement Bio::EnsEMBL::DBSQL::DBConnection::add_limit_clause | ( | ) |
Arg [1] : string $sql Arg [2] : int $max_number Example :
Description: Giving an SQL statement, it adds a limit clause, dependent on the database
(in MySQL, should add a LIMIT at the end, MSSQL uses a TOP clause)
Returntype : String containing the new valid SQL statement
Exceptions : none
Caller : general
Status : at risk
Code:
| public void Bio::EnsEMBL::DBSQL::DBConnection::connect | ( | ) |
Example :
Description: Connects to the database using the connection attribute
information.
Returntype : none
Exceptions : none
Caller : new, db_handle
Status : Stable
Code:
| public Undef Bio::EnsEMBL::DBSQL::DBConnection::connected | ( | ) |
Example :
Description: Boolean which tells if DBConnection is connected or not. State is set internally, and external processes should not alter state. Returntype : undef or 1 Exceptions : none Caller : db_handle, connect, disconnect_if_idle, user processes Status : Stable
Code:
| public DBI Bio::EnsEMBL::DBSQL::DBConnection::db_handle | ( | ) |
Arg [1] : DBI Database Handle $value Example :
Description: Getter / Setter for the Database handle used by this
database connection.
Returntype : DBI Database Handle
Exceptions : none
Caller : new, DESTROY
Status : Stable
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::dbname | ( | ) |
Arg [1] : (optional) string $arg
The new value of the database name used by this connection.
Example : Description: Getter/Setter for the name of the database used by this
connection. There is currently no point in setting this value
after the connection has already been established by the
constructor.
Returntype : string
Exceptions : none
Caller : new
Status : Stable
Code:
| public Bio::EnsEMBL::DBSQL::DBConnection::disconnect_count | ( | ) |
Undocumented method
Code:
| public Boolean Bio::EnsEMBL::DBSQL::DBConnection::disconnect_if_idle | ( | ) |
Arg [1] : none Example :
Description: Disconnects from the database if there are no currently active
statement handles.
It is called automatically by the DESTROY method of the
Bio::EnsEMBL::DBSQL::SQL::StatementHandle if the
disconect_when_inactive flag is set.
Users may call it whenever they want to disconnect. Connection will
reestablish on next access to db_handle()
Returntype : 1 or 0
1=problem trying to disconnect while a statement handle was still active
Exceptions : none
Caller : Bio::EnsEMBL::DBSQL::SQL::StatementHandle::DESTROY
Bio::EnsEMBL::DBSQL::DBConnection::do
Status : Stable
Code:
| public Boolean Bio::EnsEMBL::DBSQL::DBConnection::disconnect_when_inactive | ( | ) |
Arg [1] : (optional) boolean $newval Example :
Description: Getter/Setter for the disconnect_when_inactive flag. If set
to true this DBConnection will continually disconnect itself
when there are no active statement handles and reconnect as
necessary. Useful for farm environments when there can be
many (often inactive) open connections to a database at once.
Returntype : boolean
Exceptions : none
Caller : Pipeline
Status : Stable
Code:
| public Result Bio::EnsEMBL::DBSQL::DBConnection::do | ( | ) |
Arg [1] : string $string
the SQL statement to prepare
Example :Description: Executes a SQL statement using the internal DBI database handle. Returntype : Result of DBI dbh do() method Exceptions : thrown if the SQL statement is empty, or if the internal database handle is not present. Caller : Adaptor modules Status : Stable
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::driver | ( | ) |
Arg [1] : (optional) string $arg
the name of the driver to use to connect to the database
Example : Description: Getter / Setter for the driver this connection uses.
Right now there is no point to setting this value after a
connection has already been established in the constructor.
Returntype : string
Exceptions : none
Caller : new
Status : Stable
Code:
| public Boolean Bio::EnsEMBL::DBSQL::DBConnection::equals | ( | ) |
Example :
Description: Equality checker for DBConnection objects Returntype : boolean Exceptions : none Caller : new Status : Stable
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::from_date_to_seconds | ( | ) |
Arg [1] : date $date Example :
Description: Giving a string representing a column of type date
applies the database function to convert to the number of seconds from 01-01-1970
Returntype : string
Exceptions : none
Caller : general
Status : at risk
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::from_seconds_to_date | ( | ) |
Arg [1] : int $seconds Example :
Description: Giving an int representing number of seconds
applies the database function to convert to a date
Returntype : string
Exceptions : none
Caller : general
Status : at risk
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::host | ( | ) |
Arg [1] : (optional) string $arg
The new value of the host used by this connection.
Example : Description: Getter/Setter for the domain name of the database host use by
this connection. There is currently no point in setting
this value after the connection has already been established
by the constructor.
Returntype : string
Exceptions : none
Caller : new
Status : Stable
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::hostname | ( | ) |
Arg [1] : (optional) string $arg
The new value of the host used by this connection.
Example :Description: Convenience alias for the host method Returntype : String
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::locator | ( | ) |
Arg [1] : none Example :
Description: Constructs a locator string for this database connection
that can, for example, be used by the DBLoader module
Returntype : string
Exceptions : none
Caller : general
Status : Stable
Code:
| public Bio::EnsEMBL::DBSQL::DBConnection Bio::EnsEMBL::DBSQL::DBConnection::new | ( | ) |
Arg [DBNAME] : (optional) string
The name of the database to connect to.
Arg [HOST] : (optional) string
The domain name of the database host to connect to.
'localhost' by default.
Arg [USER] : string
The name of the database user to connect with
Arg [PASS] : (optional) string
The password to be used to connect to the database
Arg [PORT] : (optional) int
The port to use when connecting to the database
3306 by default if the driver is mysql.
Arg [DRIVER] : (optional) string
The type of database driver to use to connect to the DB
mysql by default.
Arg [DBCONN] : (optional)
Open another handle to the same database as another connection
If this argument is specified, no other arguments should be
specified.
Arg [DISCONNECT_WHEN_INACTIVE]: (optional) boolean
If set to true, the database connection will be disconnected
everytime there are no active statement handles. This is
useful when running a lot of jobs on a compute farm
which would otherwise keep open a lot of connections to the
database. Database connections are automatically reopened
when required.Do not use this option together with RECONNECT_WHEN_CONNECTION_LOST.
Arg [WAIT_TIMEOUT]: (optional) integer
Time in seconds for the wait timeout to happen. Time after which
the connection is deleted if not used. By default this is 28800 (8 hours)
on most systems.
So set this to greater than this if your connection are getting deleted.
Only set this if you are having problems and know what you are doing.
Arg [RECONNECT_WHEN_CONNECTION_LOST]: (optional) boolean
In case you're reusing the same database connection, i.e. DISCONNECT_WHEN_INACTIVE is
set to false and running a job which takes a long time to process (over 8hrs),
which means that the db connection may be lost, set this option to true.
On each prepare or do statement the db handle will be pinged and the database
connection will be reconnected if it's lost.Example :
Description: Constructor for a Database Connection. Any adaptors that require
database connectivity should inherit from this class.
Returntype : Bio::EnsEMBL::DBSQL::DBConnection
Exceptions : thrown if USER or DBNAME are not specified, or if the database
cannot be connected to.
Caller : Bio::EnsEMBL::Utils::ConfigRegistry ( for newer code using the registry)
Bio::EnsEMBL::DBSQL::DBAdaptor ( for old style code)
Status : Stable
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::pass | ( | ) |
Arg [1] : (optional) string $arg
The new value of the password used by this connection.
Example :Description: Convenience alias for the password method Returntype : String
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::password | ( | ) |
Arg [1] : (optional) string $arg
The new value of the password used by this connection.
Example : Description: Getter/Setter for the password of to use for this
connection. There is currently no point in setting
this value after the connection has already been
established by the constructor.
Returntype : string
Exceptions : none
Caller : new
Status : Stable
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::port | ( | ) |
Arg [1] : (optional) int $arg
the TCP or UDP port to use to connect to the database
Example : Description: Getter / Setter for the port this connection uses to communicate
to the database daemon. There currently is no point in
setting this value after the connection has already been
established by the constructor.
Returntype : string
Exceptions : none
Caller : new
Status : Stable
Code:
| public DBI Bio::EnsEMBL::DBSQL::DBConnection::prepare | ( | ) |
Arg [1] : string $string
the SQL statement to prepare
Example : Description: Prepares a SQL statement using the internal DBI database handle
and returns the DBI statement handle.
Returntype : DBI statement handle
Exceptions : thrown if the SQL statement is empty, or if the internal
database handle is not present
Caller : Adaptor modules
Status : Stable
Code:
| public DBI Bio::EnsEMBL::DBSQL::DBConnection::prepare_cached | ( | ) |
Arg [1] : string $string
the SQL statement to prepare
Example : Description: Prepares a SQL statement using the internal DBI database handle
and returns the DBI statement handle. The prepared statement is
cached so that it does not have to be prepared again. If only a subset of rows are required, finish() should be called
on the object to free up the statement handle.For further information please consult https://metacpan.org/pod/DBI#prepare_cached Returntype : DBI statement handle Exceptions : thrown if the SQL statement is empty, or if the internal database handle is not present Caller : Adaptor modules Status : Experimental
Code:
| public void Bio::EnsEMBL::DBSQL::DBConnection::prevent_disconnect | ( | ) |
Arg[1] : CodeRef $callback Example :
Description : A wrapper method which prevents database disconnection for the
duration of the callback. This is very useful if you need
to make multiple database calls avoiding excessive database
connection creation/destruction but still want the API
to disconnect after the body of work.The value of disconnect_when_inactive() is set to 0 no matter what the original value was & after $callback has been executed. If disconnect_when_inactive() was already set to 0 then this method will be an effective no-op. Returntype : None Exceptions : Raised if there are issues with reverting the connection to its default state. Caller : DBConnection methods Status : Beta
Code:
| public Bio::EnsEMBL::DBSQL::DBConnection::query_count | ( | ) |
Undocumented method
Code:
| public ArrayRef Bio::EnsEMBL::DBSQL::DBConnection::quote_identifier | ( | ) |
Arg [n] : scalar/ArrayRef Example :
Description: Executes the DBI quote_identifier method which will quote
any given string using the database driver's quote character.
Returntype : ArrayRef
Exceptions : None
Caller : General
Status : Stable
Code:
| public void Bio::EnsEMBL::DBSQL::DBConnection::reconnect | ( | ) |
Example :
Description: Reconnects to the database using the connection attribute
information if db_handle no longer pingable.
Returntype : none
Exceptions : none
Caller : new, db_handle
Status : Stable
Code:
| public Boolean Bio::EnsEMBL::DBSQL::DBConnection::reconnect_when_lost | ( | ) |
Arg [1] : (optional) boolean $newval Example :
Description: Getter/Setter for the reconnect_when_lost flag. If set
to true the db handle will be pinged on each prepare or do statement
and the connection will be reestablished in case it's lost.
Useful for long running jobs (over 8hrs), which means that the db
connection may be lost.
Returntype : boolean
Exceptions : none
Caller : Pipeline
Status : Stable
Code:
| public Bio::EnsEMBL::Utils::SqlHelper Bio::EnsEMBL::DBSQL::DBConnection::sql_helper | ( | ) |
Example :
Description: Lazy generated instance of Bio::EnsEMBL::Utils::SqlHelper which provides useful wrapper methods for interacting with a DBConnection instance. Returntype : Bio::EnsEMBL::Utils::SqlHelper Exceptions : none Caller : general Status : Stable
Code:
| public Bio::EnsEMBL::DBSQL::DBConnection::timeout | ( | ) |
Undocumented method
Code:
| public Hash Bio::EnsEMBL::DBSQL::DBConnection::to_hash | ( | ) |
Example :
Description: Provides a hash which is compatible with the
parameters for DBConnection's new() method. This can be
useful during serialisation
Returntype : Hash
Exceptions : none
Caller : general
Status : New
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::user | ( | ) |
Arg [1] : (optional) string $arg
The new value of the username used by this connection.
Example :Description: Convenience alias for the username method Returntype : String
Code:
| public String Bio::EnsEMBL::DBSQL::DBConnection::username | ( | ) |
Arg [1] : (optional) string $arg
The new value of the username used by this connection.
Example : Description: Getter/Setter for the username used by this
connection. There is currently no point in setting this value
after the connection has already been established by the
constructor.
Returntype : string
Exceptions : none
Caller : new
Status : Stable
Code:
| public Any Bio::EnsEMBL::DBSQL::DBConnection::work_with_db_handle | ( | ) |
Arg [1] : CodeRef $callback Example :
Description: Gives access to the DBI handle to execute methods not normally
provided by the DBConnection interface
Returntype : Any from callback
Exceptions : If the callback paramater is not a CodeRef; all other
errors are re-thrown after cleanup.
Caller : Adaptor modules
Status : Stable
Code: