{"id":17286609,"url":"https://github.com/louis70109/testcontainer-fastapi-example","last_synced_at":"2026-05-08T18:32:33.334Z","repository":{"id":106305591,"uuid":"434543316","full_name":"louis70109/testcontainer-fastapi-example","owner":"louis70109","description":"Test Container Python(FastAPI) Example with PostgreSQL","archived":false,"fork":false,"pushed_at":"2021-12-27T08:01:15.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T17:19:11.083Z","etag":null,"topics":["fastapi","postgresql","python","testcontainers"],"latest_commit_sha":null,"homepage":"https://nijialin.com/2021/11/25/python-testcontainer-fasstapi-database/","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/louis70109.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}},"created_at":"2021-12-03T09:45:50.000Z","updated_at":"2021-12-27T08:01:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"364b2208-5b97-4276-bde9-1a513b7b74da","html_url":"https://github.com/louis70109/testcontainer-fastapi-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/louis70109/testcontainer-fastapi-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louis70109%2Ftestcontainer-fastapi-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louis70109%2Ftestcontainer-fastapi-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louis70109%2Ftestcontainer-fastapi-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louis70109%2Ftestcontainer-fastapi-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/louis70109","download_url":"https://codeload.github.com/louis70109/testcontainer-fastapi-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louis70109%2Ftestcontainer-fastapi-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32792073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fastapi","postgresql","python","testcontainers"],"created_at":"2024-10-15T09:59:43.124Z","updated_at":"2026-05-08T18:32:33.314Z","avatar_url":"https://github.com/louis70109.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example for develops FastAPI in CONTAINER with VSCode\n\nFollowing are Chinese contents:\n- [如何在 VSCode 中以 Container 方式開發 FastAPI + PostgreSQL](https://nijialin.com/2021/05/29/fastapi-dev-in-container-vscode/)\n- [【tetcontainer】使用 Python 在 Docker 中做資料庫的測試案例 | 來賓: PostgreSQL, Docker, Python, GitHub Actions](https://nijialin.com/2021/11/25/python-testcontainer-fasstapi-database/)\n\n## Prerequisite\n\n- VSCode\n  - Extension\n    - Python\n    - Remote Container\n- Docker Desktop\n\n## Development\n\n- Open project with VSCode.\n- Install `Remote - Containers` VSCode dependency.\n- Press `Command` + `Shift` + `p` (Mac).\n- Input `Remote Containers: Reopen in Container`.\n- Left-side you will find `Run \u0026 Debug`, click it and find `►` button.\n- Choose `Python: FastAPI` to run this project.\n- Then bottom-side would become different color.(Mean you run success)\n\n## Reference\n\n- [How to access the database from unit test in Fast API?](https://stackoverflow.com/questions/65982681/how-to-access-the-database-from-unit-test-in-fast-api)\n\n## Backup\n\n```\nAttributeError: 'generator' object has no attribute 'query'\n```\n\n`get_db()` is not an sqlalchemy session object but rather a generator that yields a session object.\n\nUse `next()` to wrap `get_db()`.\n\nrefs: https://stackoverflow.com/questions/65982681/how-to-access-the-database-from-unit-test-in-fast-api\n\n### I can run Testcontainer at local, but why my LINE Bot function fail in GitHub Actions?\n\nBecause we ran LINE Bot development and testing with `.env` file for environment variable.\nSo LINE Bot webhook could init success in testing.\n\nNext, when your repo push to GitHub, you just set a real LINE Bot `channel_access_token` and `channel_secret` at GitHub Actions for testing, that your would success in testing.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouis70109%2Ftestcontainer-fastapi-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouis70109%2Ftestcontainer-fastapi-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouis70109%2Ftestcontainer-fastapi-example/lists"}