| Home | Trees | Indices | Help |
|
|---|
|
|
Plugin for data stored in SQL servers.
This plugin should work with any database module that conforms with the
Python DB-API 2 specification:
http://www.python.org/peps/pep-0249.html
You can find a list of database modules here:
http://www.python.org/topics/database/modules.html
It currently has been tested with SQLite, MySQL and PostgreSQL.
TODO: add support for OFFSET and LIMIT if a slice is requested? This is
part of ANSI SQL, IIRC.
|
|||
| Handler | ||
|
|||
|
filter1(vars_) Dynamic filter for converting special values into numbers. |
||
|
split_dsn(location) Split DSN into user, password, host, port and dbname. |
||
|
parse_queries(queries,
vars_,
cols=None) Build SQL query from DAP queries. |
||
|
_get_conn(dsn) Build the connection. |
||
|
_conn_sqlite(location) SQLite connection. |
||
|
_conn_pgsql(location) PostgreSQL connection. |
||
|
_conn_mysql(location) MySQL connection. |
||
|
_conn_oracle(location) Oracle connection. |
||
| _test() | ||
|
|||
|
__author__ = 'Roberto De Almeida <rob@pydap.org>'
|
||
|
extensions = '^.*\\.(sql|SQL)$'
|
||
|
DATETIME_DEFAULT_UNITS = 'years since 1-1-1'
|
||
|
TIMEDELTA_DEFAULT_UNITS = 'years'
|
||
|
MISSING_VALUE = -9999
|
||
Imports: os, ConfigParser, urllib, re, itertools, datetime, sys, coards.to_udunits, dap, dtypes, server.BaseHandler, util.safeeval.expr_eval, exceptions.ConstraintExpressionError, helper.parse_querystring
|
|||
|
>>> print split_dsn('user:pass@host:80/db') ('user', 'pass', 'host', '80', 'db') >>> print split_dsn('host/db') (None, None, 'host', None, 'db') >>> print split_dsn('user@host/db') ('user', None, 'host', None, 'db') >>> print split_dsn('user:pass@host/db') ('user', 'pass', 'host', None, 'db') |
>>> vars_ = ['index', 'site'] >>> parse_queries(['index>=11'], vars_) '(index >= 11)' >>> parse_queries(['site=~".*_St"'], vars_) Traceback (most recent call last): ... ConstraintExpressionError: 'Regular expressions disallowed!' >>> parse_queries(['site=~".*_St"', 'index>=11'], vars_) Traceback (most recent call last): ... ConstraintExpressionError: 'Regular expressions disallowed!' >>> parse_queries(['site={"Diamond_St", "Blacktail_Loop"}'], vars_) "((site = 'Diamond_St') OR (site = 'Blacktail_Loop'))" >>> parse_queries(['index={10, 12}'], vars_) '((index = 10) OR (index = 12))' |
|
|
|
|
|
|
|
|||
__author__None
|
extensionsNone
|
DATETIME_DEFAULT_UNITSNone
|
TIMEDELTA_DEFAULT_UNITSNone
|
MISSING_VALUENone
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0alpha3 on Mon Nov 13 21:49:06 2006 | http://epydoc.sourceforge.net |