connect is a method of the sapdb.sql module. You can use this method to generate a database connection.
connect(database_user, password, database_name [, host [, config]])
Parameter |
Description |
|
database_user |
Name of the database user (case-sensitive) |
|
password |
Password of the database user |
|
database_name |
Name of the database instance |
|
host |
Name of the database computer. |
|
config |
String with additional connection options in the format keyword=value[&keyword=value]... You can specify the following connection options: |
|
Keyword |
Value |
|
sqlmode |
INTERNAL | ORACLE The default value is INTERNAL |
|
isolation |
||
timeout |
Maximum period of inactivity for a database session in seconds (See also: Timeout Value) |
|
cachelimit |
The cache limit of the database session in KB |
|
autocommit |
Autocommit mode
ON |
OFF ON: After each SQL statement, the transaction is ended with a COMMIT. OFF: The user must control the transaction manually using the Rollback and Commit methods. |
|
genericResults |
ON | OFF ON: The sql and sqlX methods of the SapDB_Session class and the execute method of the SapDB_Prepared class return an object of the SapDB_Result class as the result. This can be useful, for example, for applications where the type of executed SQL statement is unknown. OFF: The SQL results can differ according to the SQL statement that is executed. |
|
component |
ODBC | CPC ODBC: The database chooses the SQL variant that is valid for ODBC. ODBC: The database chooses the SQL variant that is valid for the Precompiler. |
The result is an object of the SapDB_Session class.
The TESTUSER database user generates a connection to the TST database on the current computer using the TEST password:
session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST')
The TESTUSER database user generates a connection to the TST database on the remoteserver computer using the TEST password:
session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST','remoteserver')
The TESTUSER database user generate a connection to the TST database on the computer with the IP address 127.0.0.1 using the TEST password:
session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST','127.0.0.1')
The TESTUSER database user generates a connection to the TST database on the current computer using the TEST password. The SQL mode is ORACLE and the command timeout is 60 seconds:
session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST','', 'sqlmode=oracle&timeout=60')