API Modules

psqlc.backup_database(args)[source]

Generate backup command for database

async psqlc.create_user_db(args)[source]

Create PostgreSQL user and database

async psqlc.describe_table(args)[source]

Show table structure

async psqlc.drop_database(args)[source]

Drop a database with confirmation

async psqlc.drop_user(args)[source]

Drop a user/role with confirmation

async psqlc.execute_query(args)[source]

Execute a custom SQL query

psqlc.find_settings_recursive(start_path: str = None, max_depth_up: int = 0, max_depth_down: int = 5, filename: str = 'settings.py') str | None[source]

Search for a file by: 1. Scanning downward from current dir (including all subdirs) 2. If not found, go upward (parent, grandparent, …) up to root,

and for each ancestor, scan its entire subtree downward.

async psqlc.get_connection(host: str, port: int, user: str, password: str, database: str = 'postgres', auto_settings: bool = True, settings_path=None, max_depth_up: int = 0, max_depth_down: str = 1)[source]

Create async database connection

psqlc.get_db_config_or_args(args)[source]

Get database config from settings or args

psqlc.get_version() str[source]

Get version from __version__.py file

psqlc.load_settings_from_path(path: str)[source]

Dynamically import a settings.py file

psqlc.main()[source]

Main entry point

psqlc.parse_django_settings(settings_path: str = None, max_depth_up: int = 0, max_depth_down: str = 1) Dict[str, Any] | None[source]

Parse Django settings.py or config files for database configuration

psqlc.print_exception()[source]
psqlc.rich_print(msg: str, color: str = '#FFFFFF', bgcolor: str = None, bold: bool = False, end: str = '\n')[source]

Print colored text using Rich

async psqlc.show_connections(args)[source]

Show active database connections

async psqlc.show_databases(args)[source]

List all databases

async psqlc.show_indexes(args)[source]

Show indexes in a table or database

async psqlc.show_size(args)[source]

Show database or table sizes

async psqlc.show_tables(args)[source]

List all tables in a database

async psqlc.show_users(args)[source]

List all database users/roles

Core Functions

Connection Management

async psqlc.get_connection(host: str, port: int, user: str, password: str, database: str = 'postgres', auto_settings: bool = True, settings_path=None, max_depth_up: int = 0, max_depth_down: str = 1)[source]

Create async database connection

psqlc.get_db_config_or_args(args)[source]

Get database config from settings or args

Configuration

psqlc.parse_django_settings(settings_path: str = None, max_depth_up: int = 0, max_depth_down: str = 1) Dict[str, Any] | None[source]

Parse Django settings.py or config files for database configuration

psqlc.find_settings_recursive(start_path: str = None, max_depth_up: int = 0, max_depth_down: int = 5, filename: str = 'settings.py') str | None[source]

Search for a file by: 1. Scanning downward from current dir (including all subdirs) 2. If not found, go upward (parent, grandparent, …) up to root,

and for each ancestor, scan its entire subtree downward.

psqlc.load_settings_from_path(path: str)[source]

Dynamically import a settings.py file

Database Operations

async psqlc.show_databases(args)[source]

List all databases

async psqlc.show_tables(args)[source]

List all tables in a database

async psqlc.show_users(args)[source]

List all database users/roles

async psqlc.show_connections(args)[source]

Show active database connections

async psqlc.show_indexes(args)[source]

Show indexes in a table or database

async psqlc.show_size(args)[source]

Show database or table sizes

Query Operations

async psqlc.describe_table(args)[source]

Show table structure

async psqlc.execute_query(args)[source]

Execute a custom SQL query

Management Operations

async psqlc.create_user_db(args)[source]

Create PostgreSQL user and database

async psqlc.drop_database(args)[source]

Drop a database with confirmation

async psqlc.drop_user(args)[source]

Drop a user/role with confirmation

psqlc.backup_database(args)[source]

Generate backup command for database

Utility Functions

psqlc.rich_print(msg: str, color: str = '#FFFFFF', bgcolor: str = None, bold: bool = False, end: str = '\n')[source]

Print colored text using Rich

psqlc.print_exception()[source]
psqlc.get_version() str[source]

Get version from __version__.py file