{"id":22196689,"url":"https://github.com/druids/django-psycopg2-extension","last_synced_at":"2025-08-11T23:07:03.473Z","repository":{"id":45112947,"uuid":"210178087","full_name":"druids/django-psycopg2-extension","owner":"druids","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-26T14:32:06.000Z","size":20,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-27T03:07:04.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/druids.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-09-22T16:23:48.000Z","updated_at":"2022-12-01T21:08:38.000Z","dependencies_parsed_at":"2025-07-27T01:30:51.524Z","dependency_job_id":"91dcbf2b-cfee-484b-b50d-206d422e0064","html_url":"https://github.com/druids/django-psycopg2-extension","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/druids/django-psycopg2-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fdjango-psycopg2-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fdjango-psycopg2-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fdjango-psycopg2-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fdjango-psycopg2-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/druids","download_url":"https://codeload.github.com/druids/django-psycopg2-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Fdjango-psycopg2-extension/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269970120,"owners_count":24505466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T14:16:06.417Z","updated_at":"2025-08-11T23:07:03.451Z","avatar_url":"https://github.com/druids.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django-psycopg2-extension\n\nLibrary contains django commands which helps to prepare and manage PostgreSQL database.\n\n## Quickstart\n\nInstall djjango-psycopg2-extension\n\n```bash\npip install django-psycopg2-extension\n```\n\nAdd psycopg2_extension to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    # Django apps...\n    'psycopg2_extension',\n]\n```\n\n## Commands\n\n### psqlinit\n\nDjango command psqlinit create a database defined in django settings. \n\nYou can define specific database settings with standard django ``DATABASE`` settings:\n\n```python\nDATABASES = {\n    'default': {\n        ...\n        'EXTENSIONS': ['postgis', 'unaccent'],  # extensions to be installed with psqlinit command\n        'SNAPSHOT_FILE': Path('data', 'sql', 'local', 'init_default.sql'), # SQL which will be loaded after database initialization\n    },\n}\n```\n\nSnapshot and extensions are automatically loaded when database is preparing for tests too.\n\n### psqlclean\n\nPostgreSQL database requires often call `VACUUM` and `REINDEX`. The command `psqlclean` performs these operations. \n\nYou can define specific database settings for psqlclean command with standard django ``DATABASE`` settings:\n\n```python\nDATABASES = {\n    'default': {\n        ...\n        'VACUUM': {\n            'EXCLUDE': ['users_user'],  # list of excluded tables\n            'TABLES': ['users_permission'],  # list of tables to vacuum, all tables are selected if the setting is not set\n            'TABLES_FULL': ['users_permission'],  # list of tables to vacuum full\n            'TABLES_REINDEX': ['users_permission'],  # list of tables to reindex\n        }\n    },\n}\n```\n\n### psqlsnapshot\n\nCommand which creates SQL dump with ``pg_dump`` script and store it to the database ``'SNAPSHOT_FILE'`` setting.\n\n### psqlviews\n\nCommand which creates views defined in ``'VIEWS'`` setting.\n\n```python\nDATABASES = {\n    'default': {\n        ...\n        'VIEWS': {\n            'MODELS': {\n                'auth.users': ['id', 'email', 'first_name', 'last_name'], # Model name and list of fields\n            },\n            'SCHEMA': 'public', # Schema name\n        }\n    }\n}\n```\n\nNow you can call `psqlviews` command to create or remove views.\n\n```bash\n./manage.py psqlviews --create\n./manage.py psqlviews --delete\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdruids%2Fdjango-psycopg2-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdruids%2Fdjango-psycopg2-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdruids%2Fdjango-psycopg2-extension/lists"}