Entering content frame

 Method connect 

Use

connect is a method of the module sapdb.sql. You use this method to generate a database connection.

Definition

connect(database_user, password, database_name [, host [, config]])

Parameter

Description

database_user

Name of the database user (case-sensitive)

password

User password

database_name

Name of the database instance

host

Name of the database host

config

String with additional connection options; has the format keyword=value[&keyword=value]...

You can specify the following connection options:

Key Word

Value

sqlmode

SQL mode

INTERNAL | ORACLE

The default is INTERNAL.

isolation

Isolation level

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
The default value is
OFF

ON: After each SQL statement, the transaction is ended with a COMMIT.

OFF: The user must control the transaction manually with the methods rollback and commit.

genericResults

ON | OFF
The default value is
OFF

ON: The methods sql and sqlX of the class SapDB_Session, and the method execute of the class SapDB_Prepared get an object of the class SapDB_Result as a result. This can be useful, for example, for applications where the type of executed SQL 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.

CPC: The database chooses the SQL variant that is valid for the Precompiler.

Result

The result is an object of the class SapDB_Session.

 

The database user TESTUSER with the password TEST generates a connection to the database TST on the current server:

session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST')

The database user TESTUSER with the password TEST generates a connection to the database TST on the server remoteserver:

session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST','remoteserver')

The database user TESTUSER with the password TEST generates a connection to the database TST on the server with the IP address 127.0.0.1:

session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST','127.0.0.1')

The database user TESTUSER with the password TEST generates a connection to the database TST on the current server. The SQL mode is ORACLE and the command timeout is 60 seconds:

session=sapdb.sql.connect ('TESTUSER', 'TEST', 'TST','', 'sqlmode=oracle&timeout=60')

 

Leaving content frame