<s> from __future__ import absolute_import <EOL> import os <EOL> import ming <EOL> from ming import Session <EOL> from ming . odm import ThreadLocalODMSession <EOL> from ming import create_datastore <EOL> from depot . fields . ming import DepotExtension <EOL> mainsession = Session ( ) <EOL> DBSession = ThreadLocalODMSession ( mainsession , extensions = ( DepotExtension , ) ) <EOL> database_setup = False <EOL> datastore = None <EOL> def setup_database ( ) : <EOL> global datastore , database_setup <EOL> if not database_setup : <EOL> datastore = create_datastore ( os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> mainsession . bind = datastore <EOL> ming . odm . Mapper . compile_all ( ) <EOL> def clear_database ( ) : <EOL> global datastore , database_setup <EOL> if not database_setup : <EOL> setup_database ( ) <EOL> try : <EOL> datastore . conn . drop_all ( ) <EOL> except TypeError : <EOL> datastore . conn . drop_database ( datastore . db ) </s>
