#NEWLINE# @ classmethod #NEWLINE# def persistent_store_exists( cls , persistent_store_name ) : #NEWLINE# #INDENT# "\n        Returns True if a persistent store with the given name exists for this app.\n\n        Args:\n          persistent_store_name(string): Name of the persistent store that will be created.\n\n        Returns:\n          bool: True if persistent store exists.\n\n\n        **Example:**\n\n        ::\n\n            from .app import MyFirstApp\n\n            result = MyFirstApp.persistent_store_exists('example_db')\n\n            if result:\n                engine = MyFirstApp.get_persistent_store_engine('example_db')\n\n        " #NEWLINE# database_manager_db = settings . TETHYS_DATABASES [ 'tethys_db_manager' ] #NEWLINE# database_manager_name = ( database_manager_db [ 'USER' ] if ( 'USER' in database_manager_db ) else 'tethys_db_manager' ) #NEWLINE# database_manager_url = 'postgresql://{0}:{1}@{2}:{3}/{4}' . format ( database_manager_name , ( database_manager_db [ 'PASSWORD' ] if ( 'PASSWORD' in database_manager_db ) else 'pass' ) , ( database_manager_db [ 'HOST' ] if ( 'HOST' in database_manager_db ) else '127.0.0.1' ) , ( database_manager_db [ 'PORT' ] if ( 'PORT' in database_manager_name ) else '5435' ) , ( database_manager_db [ 'NAME' ] if ( 'NAME' in database_manager_db ) else 'tethys_db_manager' ) ) #NEWLINE# full_db_name = '_' . join ( ( cls . package , persistent_store_name ) ) #NEWLINE# engine = create_engine ( database_manager_url ) #NEWLINE# connection = engine . connect ( ) #NEWLINE# existing_dbs_statement = "SELECT d.datname as name FROM pg_catalog.pg_database d LEFT JOIN pg_catalog.pg_user u ON d.datdba = u.usesysid WHERE d.datname = '{0}';" . format ( full_db_name ) #NEWLINE# existing_dbs = connection . execute ( existing_dbs_statement ) #NEWLINE# connection . close ( ) #NEWLINE# for existing_db in existing_dbs : #NEWLINE# #INDENT# if ( existing_db . name == full_db_name ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# return False