simpleml.utils.postgres

Util module to manage postgres specific functions

Module Contents

Functions

create_database(connection_params, database, owner=None, raise_error=True)

Creates a new database

create_user(connection_params, user, password, raise_error=True)

Creates a new user

drop_database(connection_params, database, force=False, raise_error=True)

Drop database -- Must have sufficient privileges

drop_user(connection_params, user, raise_error=True)

Drop a user -- Must have sufficient privileges

run_sql_command(connection_params, command, autocommit=False)

Execute command directly using psycopg2 cursor

Attributes

__author__

simpleml.utils.postgres.__author__ = Elisha Yadgaran[source]
simpleml.utils.postgres.create_database(connection_params, database, owner=None, raise_error=True)[source]

Creates a new database :return: None

simpleml.utils.postgres.create_user(connection_params, user, password, raise_error=True)[source]

Creates a new user :return: None

simpleml.utils.postgres.drop_database(connection_params, database, force=False, raise_error=True)[source]

Drop database – Must have sufficient privileges :return: None

simpleml.utils.postgres.drop_user(connection_params, user, raise_error=True)[source]

Drop a user – Must have sufficient privileges :return: None

simpleml.utils.postgres.run_sql_command(connection_params, command, autocommit=False)[source]

Execute command directly using psycopg2 cursor

Parameters
  • connection_params – dict of connection details

  • command – raw sql to execute

  • autocommit – default false; determines if the connection automcommits

commands. Necessary for certain commands (create/drop db)