SQLAWebtrends

SQL Alchemy dialect for querying Webtrends reports


License
MulanPSL-2.0
Install
pip install SQLAWebtrends==1.0.9

Documentation

SQLAWebtrends is an SQLAlchemy dialect to connect to a Webtrends analytics reporting web service via a Windows ODBC connection, allowing you to query the reports as if they were tables in a relational database, using the SQLAlchemy ORM.

Requirements

  • SQLAlchemy >= 0.5
  • PyODBC >= 2.0
  • Webtrends Windows ODBC driver

Installation

Install SQLAWebtrends using easy_install:

easy_install sqlawebtrends

Or from the setup script:

python setup.py install

Usage

To connect to Webtrends you just have to provide SQLAlchemy with the right DSN, in the form:

"webtrends+pyodbc://%(username)s:%(password)s@%(host)s:%(port)d/%(schema)s?dsn=%(dsn)s&profile_guid=%(profile_guid)"

E.g. to connect using a local DSN called "Webtrends", to a profile called "qweertyuip.wlp", and a template called "lkjhgfdsa", using username "wes" and password "password", at the web service "analytics.mywthosting.com", you would use:

from sqlalchemy import create_engine
engine = create_engine(
    "webtrends+pyodbc://wes:password@analytics.mywthosting.com:80/lkjhgfdsa?dsn=Webtrends&profile_guid=qweertyuip.wlp"
)

One caveat for using this dialect is that you must use yield_per(1) on every query, otherwise the PyODBC cursor won't yield results correctly on iteration, e.g.:

query = session.query(MyModel).filter(some_column="test").yield_per(1)
for r in query:
    print r.some_column