Skip to content

Instantly share code, notes, and snippets.

@clofresh
Created December 2, 2008 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clofresh/30999 to your computer and use it in GitHub Desktop.
Save clofresh/30999 to your computer and use it in GitHub Desktop.
def get_db():
db = getattr(get_db, 'db', db_connection())
get_db.db = db
return db
def func1():
db = get_db()
db.execute('SELECT * FROM things')
def func2():
db = get_db()
db.execute('SELECT * FROM other_things')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment