My favorites | Sign in
Project Home Downloads Wiki
Search
for
DatabaseStorage  
Database Storage
Updated Oct 4, 2011 by cgoldberg

Database Storage for Test Data and Results

Test data and results can be stored to a database when a test run completes. To enable database storage, you must add a results_database option to your config.cfg, which defines the db connection string.

example:

results_database: sqlite:///results.db

Database storage requires sqlalchemy: http://www.sqlalchemy.org

Several database back-ends are available to choose from:
http://www.sqlalchemy.org/docs/dbengine.html#supported-databases

Example connection strings:

SQLitesqlite:///dbname
MySQLmysql://user:password@localhost/dbname
PostgreSQLpostgresql://user:password@host:port/dbname
MS SQL Servermssql://mydsn

* SQLite is supported natively by Python, so there is no installation or configuration necessary.
* The results database is created automatically on first use, no need to run your own DDL code.

Results Database Diagram

Sample DB Query Code

Here is some sample code for retrieving results from the database via sqlalchemy:

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from lib.resultsloader import ResultRow
from lib.resultsloader import GlobalConfig
from lib.resultsloader import UserGroupConfig
from lib.resultsloader import TimerRow

engine = create_engine('sqlite:///results.db')
session = sessionmaker(bind=engine)
current = session()

for rr in current.query(ResultRow).order_by(ResultRow.trans_count):
    print rr
    print rr.global_config
    print rr.global_config.user_group_configs
    print rr.timers
Powered by Google Project Hosting