Metadata-Version: 1.0
Name: gocept.testdb
Version: 0.3
Summary: Creates and drops temporary databases for testing purposes.
Home-page: UNKNOWN
Author: gocept
Author-email: mail@gocept.com
License: ZPL 2.1
Description: gocept.testdb
        -------------
        
        Creates and drops temporary databases for testing purposes.
        
        
        gocept.testdb - temporary database creation
        -------------------------------------------
        
        gocept.testdb provides small helper classes that create and drop temporary
        databases.
        
        >>> import os.path
        >>> import sqlalchemy
        >>> import gocept.testdb
        >>> schema = os.path.join(os.path.dirname(gocept.testdb.__file__), 'sample.sql')
        
        First, create a test database object
        
        >>> db = gocept.testdb.MySQL(schema_path=schema)
        
        This will use the appropriate command-line tools to create a database with a
        random name (you can specify a prefix if desired).
        Login information can be specified via environment variables
        (MYSQL_HOST default localhost, MYSQL_USER default None, MYSQL_PASS default None)
        
        The dbapi DSN can then be used to connect to the database:
        
        >>> db.dsn
        'mysql://localhost/testdb-...'
        >>> engine = sqlalchemy.create_engine(db.dsn)
        
        The database is marked as a testing database by creating a table called
        'tmp_functest' in it:
        
        >>> conn = engine.connect()
        >>> ignore = conn.execute('SELECT * from tmp_functest')
        
        If you passed a schema_path to the constructor, the SQL code in this file
        is executed, e. g. to set up tables:
        
        >>> ignore = conn.execute('SELECT * from foo')
        
        When done, simply drop the database:
        
        >>> db.drop()
        >>> engine.connect().execute('SELECT * from tmp_functest')
        Traceback (most recent call last):
          ...
        OperationalError:...
        
        
        The same procedure also works for PostgreSQL:
        (Note however that POSTGRES_PASS is not supported at the moment)
        
        >>> db = gocept.testdb.PostgreSQL(schema_path=schema)
        >>> engine = sqlalchemy.create_engine(db.dsn)
        >>> conn = engine.connect()
        >>> ignore = conn.execute('SELECT * from tmp_functest')
        >>> ignore = conn.execute('SELECT * from foo')
        >>> conn.invalidate()
        >>> db.drop()
        >>> engine.connect().execute('SELECT * from tmp_functest')
        Traceback (most recent call last):
          ...
        OperationalError:...
        
        
        =======
        Changes
        =======
        
        0.3 (2010-10-15)
        ----------------
        
        - PostgresQL: Don't call creadb/dropdb with ``--quite`` but only psql.
        
        0.2 (2009-02-26)
        ----------------
        
        - implemented authentication with password for mysql.
          Passwords for postgres are still not supported, though.
        
        0.1 (2008-09-26)
        ----------------
        
        - first release
        
Platform: UNKNOWN
