| |
- dburlparse(url)
- Function to parse a URL string and return a tuple with its various
components. This module works specifically on dburls, not on any other
RFC(1738, 1808, 2396) compliant URLs. The dburl has a simpler schema
to identify a database source along with its relevant components to
access it. Some examples of dburls are as follows:
rdb:pgdb//myhost.example.com:9999/mydb
Here schema for access is rdb, database driver name is pgdb, database
server host is myhost.example.com, the server-port is 9999 and database
name is mydb.
rdb:mysqldb//user@password:myhost.example.com:3333/mydb
Here schema for access is rdb, database driver name is mysqldb,
database user name is user, the password for the same user is password,
database server host is myhost.example.com, server-port is 3333 and
database name is mydb.
rdb:pgdb///var/sock/pg.sock/mydb
Here schema for access is rdb, database driver name is pgdb, disk based
database socket file is /var/sock/pg.sock and database name is mydb.
rdb:oracle//user@password:/var/sock/pg.sock/mydb
Here schema for access is rdb, database driver name is oracle,
database user name is user, the password for that user is password,
database socket file is /var/sock/pg.sock and database name is mydb.
ldap://user@password:myhost.example.com:389/"o=Prangya Technologies, c=IN"
Here schema for access is ldap, ldap user name(if applicable, else
dummy) is user, the password for this user is password, ldap host is
myhost.example.com, ldap server port is 389 and basedn is
"o=Prangya Technologies, c=IN".
Note: Access scheme rdb is used for relational databases accessible by SQL.
Parameters:
url: A sting containing database URL.
Returns: A tuple with items in following index positions:
0 -> addressing scheme i.e. http, rdb, ldap etc.
1 -> database driver name
2 -> user name
3 -> password
4 -> host name or socket file path
5 -> port number
6 -> database name
These index positions are also defined in constants DBURL_SCHEME,
DBURL_DRIVER, DBURL_USER, DBURL_PASSWORD, DBURL_HOST, DBURL_PORT
and DBURL_DB respectively.
Note: There are certain logical or implementation dependent constraints
applicable on the construction of dburl from various sub-components.
They are as follows:
* The user name and password can not be specified simultaneously as null.
In that case use the dburl of the form rdb:pgdb//myhost.example.com/mydb
instead of rdb:pgdb//@:myhost.example.com/mydb.
* There can't be a null user name and not-null password.
* The password can be null if a valid user name is specified. Hence the
dburl rdb:pgdb//user@:myhost.example.com/mydb is valid.
* The driver name should never contain either colon(:) or front slash(/).
* The user name should never contain at(@) character.
* The password should never contain colon(:) character.
* The host name should never contain front slash(/) character.
* The host name or socket file name should never contain colon(:) character.
* The database name should not contain front slash(/) or colon(:)
characters.
* The port number is not checked for its validity as far as its range is
concerned.
* The port number should never be present when a sockfile is being used.
Logical, isn't it?
|