Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (34 sloc) 1.23 KB
# This is just a hack to simulate the minimal api of psycopg2 for the purposes
# of a demo. There is nothing of any real interest here, please move along.
class FakeDatabaseObjects(object):
# This class provides an interface to a fake relational database
# loosely modeled after the psycopg2 library. It actually does nothing
# at all execept offer an API and track if it is in a transaction or not.
in_transaction = 0
def connect(dsn):
print 'connnected to database with "%s"' % dsn
FakeDatabaseObjects.in_transaction = 1
return FakeDatabaseObjects
def cursor():
print 'new cursor created'
return FakeDatabaseObjects
def execute(sql):
print 'executing: "%s"' % sql
def close():
print 'closing connection'
def commit():
FakeDatabaseObjects.in_transaction = 0
print 'commiting transaction'
def rollback():
FakeDatabaseObjects.in_transaction = 0
print 'rolling back transaction'
def get_transaction_status():
return FakeDatabaseObjects.in_transaction
Jump to Line
Something went wrong with that request. Please try again.