| |
- dbconnect(**kwargs)
- Method to transform the parameters for connect() function of python database
driver modules. Unfortunately there is no standards available for
either the positions of the arguments or the keywords required (for
**kwargs type parameters) for function connect(). Though almost all major
database driver modules available are "Python Database API Specification
2.0" compliant, the specs itself does not lay down any strict rules in this
area. This affects the writing of clean database independent frameworks
for software applications.
This method can be considered as a hack to overcome such problems. It takes
the parameters being supplied to the connect() method along with the module
itself and does required transformations on it after which the function
connect() is called.
Parameters:
**kwargs: A dictionary containing following keys and respective values:
module: A loaded python database driver module.
name: The name of this module.
host: Name of the host on which the database server is running.
port: The port number on which the server is listening.
database: The name of the database.
user: The user name required to connect to the database.
password: The password required for that user.
unixsocket: The disk based unix socket.
All keys are compulsory, though any of them can be empty string. In
such cases those parameters are not supplied to the function connect().
Returns: A database connection object obtained by calling function connect()
of supplied database driver module.
Raises:
ParamException: Some required parameters are missing.
Note: Database module based exception "Error" or its subclasses are
raised too. It happens whenever the connection operation fails.
Those exceptions are not caught and handled here. The calling
program is expected (and best suited) to handle them.
|