def create_datastore(self, datastore_name=None, create_indexes=True, profile=None):
        qual_ds_name = self._get_datastore_name(datastore_name)
        profile = profile or self.profile or DEFAULT_PROFILE
        log.info('Creating datastore %s (create_indexes=%s, profile=%s)' % (qual_ds_name, create_indexes, profile))
        if profile == DataStore.DS_PROFILE.DIRECTORY:
            profile = DataStore.DS_PROFILE.RESOURCES

        profile = profile.lower()
        if not os.path.exists("res/datastore/postgresql/profile_%s.sql" % profile):
            profile = "basic"
        profile_sql = None
        with open("res/datastore/postgresql/profile_%s.sql" % profile, "r") as f:
            profile_sql = f.read()

        with psycopg2_connect(c_host=self.host, c_port=self.port, c_dbname=self.database,
                              c_user=self.admin_username, c_password=self.admin_password,
                              tracer=self._call_tracer, trace_stmt="EXECUTE profile_%s.sql" % profile) as conn:
            conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
            with conn.cursor() as cur:
                try:
                    cur.execute(profile_sql % dict(ds=qual_ds_name))
                except ProgrammingError:
                    raise BadRequest("Datastore with name %s already exists" % datastore_name)
                except DatabaseError as de:
                    raise BadRequest("Datastore %s create error: %s" % (datastore_name, de))
                except Exception as de:
                    raise BadRequest("Datastore %s create error: %s" % (datastore_name, de))
        log.debug("Datastore '%s' created" % (qual_ds_name))
Create a datastore with the given name and profile.
dataset/ETHPy150Open ooici/pyon/pyon/datastore/postgresql/base_store.py/PostgresDataStore.create_datastore