foliolib.helper.database.Postgres
- class foliolib.helper.database.Postgres(user: str = None, password: str = None, database: str = 'postgres', host: str = None, port: str = None)
Bases:
objectPostgres config can be defined in $HOME/.foliolib/[SERVERNAME]/server.conf:
[Postgres] host = localhost port = 5432 user = postgres password = password
Example:
with Postgres(database="okapi_modules") as pg: print(pg.get_schemas()) pg.cursor.execute("SELECT * FROM TABLENAME;") print(pg.cursor.fetchall())
Methods
clear_table(table[, schema])close()create_database(dbname, user)create_schema(schema[, user])create_user(user, password[, roles])delete_rows_from_table(table[, schema, ids])drop_database(dbname[, force])drop_schema(schema)drop_table(table[, schema])drop_user(user)drop_users_for_tenant(tenant)get_table_column_names(table[, schema])get_table_data(table[, schema, id_])get_table_row_count(table[, schema])get_tables(schema)is_open()open()- clear_table(table: str, schema: str = None)
- close()
- create_database(dbname: str, user: str)
- create_schema(schema: str, user: str = None)
- create_user(user: str, password: str, roles: list = [])
- delete_rows_from_table(table: str, schema: str = None, ids=[])
- drop_database(dbname: str, force=False)
- drop_schema(schema: str)
- drop_table(table: str, schema: str = None)
- drop_user(user: str)
- drop_users_for_tenant(tenant: str)
- get_databases()
- get_descriptors()
- get_schemas()
- get_table_column_names(table: str, schema: str = None)
- get_table_data(table: str, schema: str = None, id_=None)
- get_table_row_count(table: str, schema: str = None)
- get_tables(schema: str)
- get_users()
- is_open()
- open()