uri
Database URI parsing
The uri module is accessible via the sqlapi module.
Functions
f parse_uri(uri) ...
Parse a URI and return a dictionary representing the parse results. This dictionary should have the following keys:
plugin:
The plugin for this URI. This plugin also parses the URI itself.
user:
Username, if given, or None if not. This key should not be provided if a username is not meaningful for this database.
password:
Like username.
host:
A host name. '' generally means localhost, but may mean through a local socket. Should not be provided if not applicable.
dbname:
The name of the database.
filename:
If the database is stored in a single file, the name of that file.
uri:
The original URI.
vars:
Any query-string parameters. Some of these may be consumed by the plugin/database connector, but should be present here anyway.
Other keys are allowed.
f remove_scheme(uri) ...
Return the URI with the scheme removed.
>>> remove_scheme('sqlite:table.db')
'table.db'
f parse_user_host(uri_wo_scheme) ...
Remove the user and host information. Returns (user, password, host, rest_of_uri). Expects to have remove_scheme() run first.
>>> parse_user_host('//pgsql@localhost/foo')
('pgsql', None, 'localhost', 'foo')
>>> parse_user_host('///test')
(None, None, '', 'test')
>>> parse_user_host('//test:pass@foo.com/bar')
('test', 'pass', 'foo.com', 'bar')
f parse_query_string(uri, strict_parsing=True) ...
Given a URI (or a fragment, as returned by parse_user_host) return (uri_without_query_string, vars). vars is a dictionary of variables in the query string (after ?). If there are duplicate variables, they will show up as a list of values.
See the source for more information.