## Method connect

### Use

connect is a method of the sdb.sql module.

Use this method to open a database session.

### Prerequisites

The database instance is in the ONLINE operational state.

### Features

connect (database_user, password, database_name , host = '' config = '')

database_user | Name of the database user
password | Password of the database user Note that the password is case-sensitive. See Concepts of the Database System, Conventions for User Names and Passwords
database_name | Name of database instance
host | Name or IP address of the database computer
config | Connection options (see below) Format: keyword=value[&keyword=value]...

Connection Options

Keyword | Possible Values | Default Value | Description
autocommit | on | off | off | AUTOCOMMIT mode on: After each SQL statement, the transaction is ended with a COMMIT. off: You control the transaction yourself with the methods commit and rollback.
cachelimit | <value in kB> | Default value of the database instance | The cache limit of the database session in KB
component | odbc | cpc | cpc | odbc: The database chooses the SQL variant that is valid for ODBC. cpc: The database chooses the SQL variant that is valid for the C++ Precompiler.
genericResults | on | off | 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 class SapDB_Result as the result. This can be useful, for example, for applications for which the SQL mode is unknown. off: The SQL results can differ according to the SQL statement that is executed.
isolation | 0 | 1 | 2 | 3 | 10 | 15 | 20 | 30 | Default value of the database instance | Isolation level
sqlmode | internal | oracle | internal | SQL mode
timeout | 0 | <value in seconds> | Default value of the database instance | Maximum inactivity time for a database session (in seconds)

Result:

● Successful execution: object of the class SapDB_Session

● Error: exception of the class CommunicationError

### Example

● Database user MONA with password RED connects to the database instance DEMODB on the local computer:

session=sdb.sql.connect ('MONA', 'RED', 'DEMODB')

● Database user MONA with password RED connects to the database instance DEMODB on the computer PARMA:

session=sdb.sql.connect ('MONA', 'RED', 'DEMODB','PARMA')

● Database user MONA with password RED connects to the database instance DEMODB on the local computer with the connection option SQL mode=ORACLE and command timeout = 60 seconds:

session=sdb.sql.connect ('MONA', 'RED', 'DEMODB','', 'sqlmode=oracle&timeout=60')

● Connecting/Closing the Connection to the Database Instance