An open API service indexing awesome lists of open source software.

https://github.com/tameronline/ll-db-builder


https://github.com/tameronline/ll-db-builder

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

# ๐Ÿ› ๏ธ ll-db-builder

**ll-db-builder** is a professional Python project that automatically sets up the PostgreSQL database for Flask-based or general systems using SQLAlchemy.
It loads connection settings from `.env`, ensures the database exists, and creates all required tables based on the defined models in `main/models`.

---

## ๐Ÿš€ Features

- โœ… Initializes all tables using SQLAlchemy
- โœ… Secure loading of settings via `.env`
- โœ… Clean and professional project structure
- โœ… Ready to integrate with CI or Flask projects

---

## ๐Ÿ“ Project Structure

```bash
ll-db-builder/
โ”œโ”€โ”€ main/
โ”‚ โ”œโ”€โ”€ config/ # Environment and configuration loading
โ”‚ โ”œโ”€โ”€ models/ # Database models
โ”‚ โ””โ”€โ”€ extensions.py # SQLAlchemy configuration
โ”œโ”€โ”€ .env # Database connection settings
โ”œโ”€โ”€ build.py # Main script to initialize DB and tables
โ”œโ”€โ”€ requirements.txt # Main project dependencies
โ”œโ”€โ”€ test-requirements.txt # Test-specific dependencies
โ””โ”€โ”€ README.md # This file
```

---

## โš™๏ธ Usage

### 1. Create a virtual environment

```bash
python -m venv venv
venv\Scripts\activate # On Windows
# or
source venv/bin/activate # On Linux/Mac

pip install -r requirements.txt
```

### 2. Configure environment variables

Create a `.env` file in the root directory with:

```env
DB_NAME=ll_db
DB_USER=postgres
DB_PASSWORD=yourpassword
DB_HOST=127.0.0.1
DB_PORT=5432
```

### 3. Run the script

```bash
python build.py
```

---

## ๐Ÿงฑ Key Files

| File | Purpose |
|------|---------|
| `build.py` | Entry point โ€“ loads config and builds database/tables |
| `config_loader.py` | Loads environment variables |
| `db_initializer.py` | Ensures DB exists and initializes tables |
| `models/*.py` | SQLAlchemy table definitions |
| `extensions.py` | Defines `db` and `Base` for reuse |

---

## ๐Ÿงช Testing (Optional)

```bash
pip install -r test-requirements.txt
pytest
```

---

## ๐Ÿ“ License

MIT License โ€“ See [LICENSE](LICENSE) for details.

---

## ๐Ÿ‘จโ€๐Ÿ’ป Author

- **Tamer Faour** โ€“ [@TamerOnLine](https://github.com/TamerOnLine)