MSSQL.specify_conn_str¶
- MSSQL.specify_conn_str(database_name=None, auth=None, password=None)[source]¶
Specify the connection string for establishing a connection to a database.
- Parameters:
database_name (str | None) – Name of the database to connect to; defaults to the currently-connected database if
database_name=None
.auth (str | None) – Authentication method used for the connection; defaults to the current authentication method if
auth=None
.password (str | int | None) – User’s password; if
password=None
(default), manual input of the correct password is required to establish the connection.
- Returns:
Connection string formatted for establishing a connection.
- Return type:
str
Examples:
>>> from pyhelpers.dbms import MSSQL >>> mssql = MSSQL(verbose=True) Connecting <server_name>@localhost:1433/master ... Successfully. >>> conn_str = mssql.specify_conn_str() >>> conn_str 'DRIVER={ODBC Driver 17 for SQL Server};SERVER={localhost};DATABASE={master};...