IDatabaseConnection¶
- class IDatabaseConnection¶
Bases:
ImpactCOMWrapperBase- Summary:
Provides methods for connecting/disconnecting database connections, support for using transactions and provides methods for creating IDatabaseQuery and IDatabaseCommand objects.
- Remarks:
There are a number of ways to create an IDatabaseConnection object: the active_database.connection property returns an IDatabaseConnection for the current Impact database. the IDatabase.connection property can also be used for any registered Impact database in the IDatabases collection. the IDatabases.create_connection method can create an IDatabaseConnection by passing arguments for the driver and connection string. Using the last two methods the IDatabaseConnection object must be connected before it can be used. Introduced in Impact 11.0.0.35.
Wraps a COM object or another wrapper instance. Accepts: - A valid impact_object - An existing impact_com_wrapper_base-derived instance
- property connected¶
Gets Connected.
- Summary:
Determines if the database is currently connected.
- Returns:
The value of Connected.
- Return type:
connected (bool)
- property connection_name¶
Gets connection_name.
- Summary:
Returns the name of the registered connection. For connections created using IDatabases.create_connection this will return “IDatabasesDynamicConnection”.
- Returns:
The value of connection_name.
- Return type:
connection_name (str)
- property connection_string¶
Gets connection_string.
- Summary:
Returns the connection string.
- Returns:
The value of connection_string.
- Return type:
connection_string (str)
- property connection_type¶
Gets connection_type.
- Summary:
Returns the connection type. Currently ODBC/ADO/ODBCDIRECT.
- Returns:
The value of connection_type.
- Return type:
connection_type (str)
- property dbms_type¶
Gets dbms_type.
- Summary:
Returns the DBMS type.
- Returns:
The value of dbms_type.
- Return type:
dbms_type (str)
- property dbms_version¶
Gets dbms_version.
- Summary:
Returns the DBMS version.
- Returns:
The value of dbms_version.
- Return type:
- property in_transaction¶
Gets in_transaction.
- Summary:
Determines if a transaction is currently running.
- Returns:
The value of in_transaction.
- Return type:
in_transaction (bool)
- property using_transactions¶
Gets using_transactions.
- Summary:
Determines if the connection supports transactions.
- Returns:
The value of using_transactions.
- Return type:
using_transactions (bool)
- begin_transaction()¶
- Summary:
Starts a transaction. This method will fail if a transaction is already running.
Examples:
- blob_length(column_name)¶
- Summary:
Returns SQL that can be used to determine the length of a BLOB column.
- Parameters:
column_name (str) – Name of column for which the length is to be determined.
- commit()¶
- Summary:
Commits changes made in a transaction. This method will fail is a transaction is not running.
- connect()¶
- Summary:
Attempts to connect to the database. This method will fail for an IDatabaseConnection obtained from the current IDatabase.
Examples:
- create_command()¶
- Summary:
Returns a new IDatabaseCommand object.
- create_query()¶
- Summary:
Returns a new IDatabaseQuery object.
- disconnect()¶
- Summary:
Disconnects the current database connection. This method will fail for an IDatabaseConnection obtained from the current IDatabase.
- execute_sql_lines(sql, individual_commits)¶
- Summary:
Execute one or more lines of SQL.
- Remarks:
This method provides a convenient way to execute multiple SQL statements in a single call. You can specify to either execute each statement using individual transactions, or to execute all statements as a batch in a single transaction. Lines must be separated with carriage return and newline characters (
in C, vbCrLf in VB). Impact splits the strings and passes them to the underlying database connection one string at a time. To prevent malicious use, the IDatabaseCommand.execute_sql and IDatabaseConnection.execute_sql_lines methods have additional security checks. When used with a normal Impact licence, any script calling these methods must be signed. For further information about script signing, please see the Impact documentation, or ask your support representative.
- param str sql:
Multiple SQL statements
- param bool individual_commits:
Determines whether to execute each statement in its own transaction
- isNone()¶
Checks if the COM object is None. This is useful for determining if the wrapper has been initialized with a valid COM object.
- new_guid()¶
- Summary:
Returns SQL that can be used to generate a GUID value.
- next_unique_key(table_name, column_name)¶
- Summary:
Generate the next unique value for any integer column in any table.
- Remarks:
This method can be used to generate the next unique value for any integer column in any table. The method takes both table_name and column_name parameters, but if the column_name is omitted or null then the primary key column of the table is used. If a transaction is running then next_unique_key will also lock row zero of the table, this matches Impact when inserting records into a table and prevents two users from trying to insert records with the same unique key simultaneously.
- Parameters:
table_name (str) – Table name
column_name (str) – Column name (optional)
Examples:
- rollback()¶
- Summary:
Rollback all changes made in a transaction. This method will fail is a transaction is not running.
- string_length(column_name)¶
- Summary:
Returns SQL that can be used to determine the length of a string column.
- Parameters:
column_name (str) – Name of column for which the length is to be determined.
Examples