{"id":31642496,"url":"https://github.com/tameronline/postgres-admin-tools","last_synced_at":"2025-10-07T03:59:59.280Z","repository":{"id":298981652,"uuid":"1001734257","full_name":"TamerOnLine/postgres-admin-tools","owner":"TamerOnLine","description":"Utility scripts for managing PostgreSQL databases and tables via SQLAlchemy and psycopg2.","archived":false,"fork":false,"pushed_at":"2025-06-13T23:46:01.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-14T00:27:42.645Z","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/TamerOnLine.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":"2025-06-13T23:09:39.000Z","updated_at":"2025-06-13T23:46:04.000Z","dependencies_parsed_at":"2025-06-14T00:37:44.037Z","dependency_job_id":null,"html_url":"https://github.com/TamerOnLine/postgres-admin-tools","commit_stats":null,"previous_names":["tameronline/postgres-admin-tools"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TamerOnLine/postgres-admin-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TamerOnLine%2Fpostgres-admin-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TamerOnLine%2Fpostgres-admin-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TamerOnLine%2Fpostgres-admin-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TamerOnLine%2Fpostgres-admin-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TamerOnLine","download_url":"https://codeload.github.com/TamerOnLine/postgres-admin-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TamerOnLine%2Fpostgres-admin-tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278717435,"owners_count":26033542,"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-10-07T02:00:06.786Z","response_time":59,"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":"2025-10-07T03:59:56.748Z","updated_at":"2025-10-07T03:59:59.272Z","avatar_url":"https://github.com/TamerOnLine.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠️ PostgreSQL Admin Tools\n\n![Build Status](https://github.com/TamerOnLine/postgres-admin-tools/actions/workflows/python-app.yml/badge.svg)\n\nA lightweight admin interface and CLI toolkit for PostgreSQL, built with **Flask**, **SQLAlchemy**, and **psycopg2**.\n\n\u003e Manage your databases and tables with ease – via web or terminal.\n\n---\n\n## 📥 Clone the Repository\nTo get started, clone this repository to your local machine using Git:\n\n```bash\ngit clone https://github.com/TamerOnLine/postgres-admin-tools.git\ncd postgres-admin-tools\n```\n- Make sure you have Git installed.\n- [You can download it from](https://git-scm.com).\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/github.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Cloning the repository via Git command line \u003c/sub\u003e\n\n---\n\n## 📦 Features\n\n- 🔐 Secure user system with Flask-Login (default admin: `admin/12345`)\n- ⚙️ Create or drop PostgreSQL databases\n- 🧱 Manage tables (create / migrate / drop) via SQLAlchemy\n- 💾 Full database backup \u0026 restore using `pg_dump` / `psql`\n- 🧩 Easy environment config via `.env` file\n- 🌐 Flask-based web UI ready out of the box\n\n---\n\n## 🎬 Demo\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/demo.gif\" alt=\"PostgreSQL Admin Tools demo\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📽️ Quick demo of the PostgreSQL Admin Tools in action\u003c/sub\u003e\n\n\n---\n\n## 🔧 Tech Stack\n\n| Technology     | Description                         |\n|----------------|-------------------------------------|\n| Python         | Core programming language           |\n| PostgreSQL     | Relational database engine          |\n| SQLAlchemy     | ORM for database modeling           |\n| psycopg2       | PostgreSQL driver for Python        |\n| python-dotenv  | Load `.env` variables into runtime  |\n\n---\n\n## 🧱 Project Structure\n\n```\npostgres-admin-tools/\n├── myapp.py                  # Flask app with login \u0026 DB panel\n├── requirements.txt\n├── LICENSE\n├── README.md\n└── models/\n    ├── models_definitions.py # SQLAlchemy models\n    └── db_postgres/\n        ├── create.py         # Create DB if not exists\n        ├── drop.py           # Drop DB (safe disconnect)\n        ├── drop_table.py     # Drop individual/all tables\n        ├── manage_tables.py  # Schema updates\n        ├── BACKUP.py         # Backup to SQL file\n        ├── RESTORE.py        # Restore from backup\n        └── db_config.py      # Load from .env\n```\n\n---\n\n## ⚙️ Environment Setup\n\nCreate a `.env` file in the root directory:\n\n```env\nDATABASE_URL=postgresql://user:password@localhost:5432/your_db\nSECRET_KEY=your_secret_here\n```\n\n---\n\n## 🚀 Quick Start\n### 1. Create Virtual Environment\n```bash\n# Windows\npy -3.12 -m venv venv\n.\\venv\\Scripts\\Activate\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/venv.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Virtual environment activated successfully\u003c/sub\u003e\n\n---\n\n```bash\n# macOS / Linux\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n---\n\n### Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/pip_install.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Installing dependencies using pip \u003c/sub\u003e\n\n---\n\n### Create Database\n\n```bash\npy .\\models\\db_postgres\\create.py\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/create.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e \n\u003csub\u003e📸 Creating PostgreSQL database\u003c/sub\u003e\n\n---\n\n### Drop Database\n\n```bash\npy .\\models\\db_postgres\\drop.py\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/drop.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Dropping the database safely\u003c/sub\u003e\n\n---\n\n### Drop Tables\n\n```bash\npy .\\models\\db_postgres\\drop_table.py\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/drop_table.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Dropping selected or all tables\u003c/sub\u003e\n\n---\n\n### Manage Tables\n\n```bash\npy .\\models\\db_postgres\\manage_tables.py\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/manage_tables.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 CLI interface to manage tables (create or sync)\u003c/sub\u003e\n\n---\n\n### Backup Database\n\n```bash\npy .\\models\\db_postgres\\BACKUP.py\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/BACKUP.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Generating SQL backup file using `pg_dump`\u003c/sub\u003e\n\n---\n\n### Restore Database\n\n```bash\npy .\\models\\db_postgres\\RESTORE.py\n```\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/RESTORE.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e\n\u003csub\u003e📸 Restoring database from SQL file\u003c/sub\u003e\n\n---\n\n## 🛡️ User System\n\nThe system automatically creates a **default admin user** on first run if no user with username `admin` is found.\n- **Username**: `admin`  \n- **Password**: `12345`\n\nTo manually trigger this, run the following command:\n\n```bash\npy .\\models\\models_definitions.py\n```\nYou can modify this logic in [`models/models_definitions.py`](models/models_definitions.py).\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"screenshots/models_definitions.png\" alt=\"models definitions\" width=\"600\"/\u003e\n\u003c/div\u003e \n\u003csub\u003e📸 Creating default admin user if not exists\u003c/sub\u003e\n\n---\n\n## 🧪 SQLite Test Mode\n\nIf `DATABASE_URL` is not set in the `.env`, the system defaults to SQLite (`sqlite:///test.db`) for quick testing.\n\n\u003e Note: Scripts like `create.py`, `BACKUP.py`, etc., require PostgreSQL and do not support SQLite.\n\n---\n\n## 📋 CLI Command Summary\n\n| Operation             | Script              | Mode            |\n|----------------------|---------------------|-----------------|\n| 🏗️ Create Database     | `create.py`          | CLI             |\n| ❌ Drop Database       | `drop.py`            | CLI             |\n| 🧹 Drop Tables         | `drop_table.py`      | Interactive CLI |\n| 🧩 Manage Tables       | `manage_tables.py`   | Interactive CLI |\n| 💾 Backup Database     | `BACKUP.py`          | CLI             |\n| ♻️ Restore from Backup | `RESTORE.py`         | Interactive CLI |\n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License.  \nSee the [LICENSE](./LICENSE) file for details.\n\n---\n\n## 👨‍💻 Author\n\n**Tamer Hamad Faour**  \nGitHub: [@TamerOnLine](https://github.com/TamerOnLine)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftameronline%2Fpostgres-admin-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftameronline%2Fpostgres-admin-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftameronline%2Fpostgres-admin-tools/lists"}