{"id":22560499,"url":"https://github.com/timonrieger/database-service","last_synced_at":"2026-04-19T14:03:11.196Z","repository":{"id":284922674,"uuid":"882843927","full_name":"timonrieger/database-service","owner":"timonrieger","description":"Shared database for flask projects","archived":false,"fork":false,"pushed_at":"2025-09-18T14:14:34.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-18T16:59:45.113Z","etag":null,"topics":["database","flask","sqlalchemy"],"latest_commit_sha":null,"homepage":"","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/timonrieger.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-03T22:29:14.000Z","updated_at":"2025-09-18T14:14:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"a209d905-a9fc-4634-80d5-dfb15a9636ac","html_url":"https://github.com/timonrieger/database-service","commit_stats":null,"previous_names":["timonrieger/database-service"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/timonrieger/database-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonrieger%2Fdatabase-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonrieger%2Fdatabase-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonrieger%2Fdatabase-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonrieger%2Fdatabase-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timonrieger","download_url":"https://codeload.github.com/timonrieger/database-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonrieger%2Fdatabase-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32009239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":["database","flask","sqlalchemy"],"created_at":"2024-12-07T21:14:25.658Z","updated_at":"2026-04-19T14:03:11.189Z","avatar_url":"https://github.com/timonrieger.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Centralized Database for Flask Applications Using SQLAlchemy\n\n## Features\n\n- Centralized database management for multiple Flask applications.\n- Easy integration with SQLAlchemy ORM.\n- Support for database migrations using Flask-Migrate.\n\n## Requirements\n\n- Flask\n- Flask-SQLAlchemy\n- Flask-Migrate\n- python-dotenv\n\n## Setup\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/timonrieger/database-service.git\n    ```\n\n2. Install the required packages:\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n3. Set up environment variables:\n    Copy the `.env.example` file in the root directory to `.env` and add your configuration settings. Use the external database URL provided by your hosting service. Ensure that all applications interacting with the database use the same connection string.\n\n## Usage\n\n### 1. Importing the Database in Your Flask App\n\nTo initialize the database, import the database module and import the `db`, the `create_all` initializer method, and all tables you need in your application. Here’s how to set it up:\n\n```python\nfrom database import db, create_all, User\nfrom dotenv import load_dotenv\nimport os\n\nload_dotenv()\napp = Flask(__name__)\n\napp.config['SECRET'] = os.getenv(\"SECRET\")\napp.config['SQLALCHEMY_DATABASE_URI'] = os.getenv(\"DB_URI\")\napp.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False\n\ndb.init_app(app)\n\nwith app.app_context():\n    create_all(app)\n```\n\n### 2. Migrations\n\nConsider using Flask-Migrate for managing database schema changes.\n\nInstall Flask-Migrate:\n```bash\npip install Flask-Migrate\n```\n\nSet up Flask-Migrate in your application:\n```python\nfrom flask_migrate import Migrate\nmigrate = Migrate(app, db)\n```\n\nRun the following commands to initialize and apply migrations:\n```bash\ncd database\nflask db init\nflask db stamp head\nflask db migrate\nflask db upgrade\n```\n\n# Git Tagging Commands\n\n1. **Create a Tag**  \n   `git tag v1.4.4`\n\n2. **Push the Tag to a Remote Repository**  \n   `git push backup v1.4.4`\n\n3. **Push Both the Main Branch and the Tag**  \n   `git push -u origin main tag v1.4.4`\n\n4. **Push All Tags to the Remote Repository (Optional)**  \n   `git push --tags`\n\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimonrieger%2Fdatabase-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimonrieger%2Fdatabase-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimonrieger%2Fdatabase-service/lists"}