parameters: (self, database)
docstring: create a database.  This is done by a system command
docstring_summary: create a database.  This is done by a system command
docstring_tokens: create a database . This is done by a system command
function: def create_database(self, database):
          '''create a database.  This is done by a system command'''
  
          # if the database already exists, do nothing
          if self.database_exists(database):
              return
  
          if not isinstance(database, basestring):
              database = database.get_database()
  
          from pyasm.search import DbResource
          db_resource = DbResource.get_default(database)
  
          # use PGPASSWORD environment variable to prevent createdb from interactively asking for a password
          pw_env = os.environ
          pw_env['PGPASSWORD'] = db_resource.get_password()
  
          create = 'createdb %s -E UNICODE "%s"' % (self._get_db_info(db_resource), database)
          print("create: ", create)
          child = subprocess.Popen(create, shell=True, env=pw_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
          stdout, stderr = child.communicate()
          if child.returncode != 0:
              raise Exception("Error creating database '%s': %s" % (database, stderr))
function_tokens: def create_database ( self , database ) : # if the database already exists, do nothing if self . database_exists ( database ) : return if not isinstance ( database , basestring ) : database = database . get_database ( ) from pyasm . search import DbResource db_resource = DbResource . get_default ( database ) # use PGPASSWORD environment variable to prevent createdb from interactively asking for a password pw_env = os . environ pw_env [ 'PGPASSWORD' ] = db_resource . get_password ( ) create = 'createdb %s -E UNICODE "%s"' % ( self . _get_db_info ( db_resource ) , database ) print ( "create: " , create ) child = subprocess . Popen ( create , shell = True , env = pw_env , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) stdout , stderr = child . communicate ( ) if child . returncode != 0 : raise Exception ( "Error creating database '%s': %s" % ( database , stderr ) )