def user_create(username, new_login_password=None, **kwargs):
 if ('database' not in kwargs):
  return False
 if user_exists(username, **kwargs):
  return False
 try:
  conn = _get_connection(**kwargs)
  conn.autocommit(True)
  cur = conn.cursor()
  if new_login_password:
   if login_exists(username, **kwargs):
    conn.close()
    return False
   cur.execute("CREATE LOGIN {0} WITH PASSWORD='{1}',check_policy = off".format(username, new_login_password))
   cur.execute('CREATE USER {0} FOR LOGIN {1}'.format(username, username))
  else:
   cur.execute('CREATE USER {0} WITHOUT LOGIN'.format(username))
  conn.autocommit(False)
  conn.close()
  return True
 except Exception as e:
  return 'Could not create the user: {0}'.format(e)

def user_create ( username , new_login_password = None , ** kwargs ) : if ( 'database' not in kwargs ) : return False if user_exists ( username , ** kwargs ) : return False try : conn = _get_connection ( ** kwargs ) conn . autocommit ( True ) cur = conn . cursor ( ) if new_login_password : if login_exists ( username , ** kwargs ) : conn . close ( ) return False cur . execute ( "CREATE LOGIN {0} WITH PASSWORD='{1}',check_policy = off" . format ( username , new_login_password ) ) cur . execute ( 'CREATE USER {0} FOR LOGIN {1}' . format ( username , username ) ) else : cur . execute ( 'CREATE USER {0} WITHOUT LOGIN' . format ( username ) ) conn . autocommit ( False ) conn . close ( ) return True except Exception as e : return 'Could not create the user: {0}' . format ( e )
creates a postgres user .