{"id":18802171,"url":"https://github.com/oracle-quickstart/fastapi-oracle-database-example","last_synced_at":"2025-08-19T05:12:10.801Z","repository":{"id":185526644,"uuid":"673677067","full_name":"oracle-quickstart/fastapi-oracle-database-example","owner":"oracle-quickstart","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-09T13:15:45.000Z","size":55,"stargazers_count":9,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T16:03:53.699Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oracle-quickstart.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":"2023-08-02T07:12:12.000Z","updated_at":"2025-02-16T18:45:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"4a142cbd-fe4d-4e06-9cf3-36ff3dc94d8b","html_url":"https://github.com/oracle-quickstart/fastapi-oracle-database-example","commit_stats":null,"previous_names":["oracle-quickstart/fastapi-oracle-database-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oracle-quickstart/fastapi-oracle-database-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-quickstart%2Ffastapi-oracle-database-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-quickstart%2Ffastapi-oracle-database-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-quickstart%2Ffastapi-oracle-database-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-quickstart%2Ffastapi-oracle-database-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oracle-quickstart","download_url":"https://codeload.github.com/oracle-quickstart/fastapi-oracle-database-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-quickstart%2Ffastapi-oracle-database-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271103202,"owners_count":24699646,"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-19T02:00:09.176Z","response_time":63,"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-11-07T22:26:52.934Z","updated_at":"2025-08-19T05:12:10.792Z","avatar_url":"https://github.com/oracle-quickstart.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI Oracle Database Example\n\nThis is an example of a Python FastAPI Web Service that interacts with Oracle Database.\n\n![FastAPI OracleDB](https://github.com/oracle-quickstart/fastapi-oracle-database-example/assets/39692236/8964ebc2-b854-403b-95d2-56c488f848c3)\n\n\n## Prerequisites\n\n- Python 3\n- Oracle Database connection details\n- curl (optional)\n\n## Installation\n\n##### 1. Clone this repository:\n\n   ```\n   git clone https://github.com/oracle-quickstart/fastapi-oracle-database-example.git\n   cd fastapi-oracle-database-example\n   ```\n\n##### 2. Install the required packages using pip:\n\n   ```\n   python3 -m pip install -r requirements.txt\n   ```\n\n##### 3. Configuration\n\n   Set database username and connection string environment variables:\n\n   PYTHON_USERNAME\n\n   PYTHON_CONNECTSTRING\n\n##### Example:\n###### Local Oracle DB\n   ```\n   export PYTHON_USERNAME=cj\n   export PYTHON_CONNECTSTRING=localhost/orclpdb1\n   ```\n\n###### Autonomous Oracle DB\n\n  ```\n   export PYTHON_USERNAME=admin\n   export PYTHON_CONNECTSTRING='(description= (retry_count=15)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.ap-sydney-1.oraclecloud.com))(connect_data=(service_name=gxxxxxx_yxxxx_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))'\n  ```\n\n##### 4. Running the FastAPI App\n\nTo run the FastAPI app, use the following command:\n\n```\nuvicorn fapi:app --reload\n```\n\nIf the uvicorn binary is not in your PATH, you may need to specify the full\npath, for example:\n\n```\n$HOME/Library/Python/3.9/bin/uvicorn fapi:app --reload\n```\n\nEnter your database user password when prompted.\n\nThe app will be accessible at http://localhost:8000 or http://YOUR_LOCAL_IP:8000\n\n##### 5. API Endpoints\n\nEndpoints are shown at http://localhost:8000/docs\n\nThey are:\n- `POST`: to create data\n- `GET`: to read data\n- `PUT`: to update data\n- `DELETE`: to delete data\n\nAlternative documentation is at http://localhost:8000/redoc\n\nTo use the FastAPI app, you can use the 'Try it out' buttons on\nhttp://localhost:8000/docs or alternatively use a command line tool such as\n`curl`.\n\n###### Create an order:\n\n```\ncurl -X 'POST' \\\n  'http://localhost:8000/orders/' \\\n  -H 'accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"order_id\": 1,\n    \"product_name\": \"New Product\",\n    \"quantity\": 10\n  }'\n```\n\n###### Update an order:\n\n```\ncurl -X 'PUT' \\\n  'http://localhost:8000/orders/1' \\\n  -H 'accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"order_id\": 1,\n    \"product_name\": \"Updated Product\",\n    \"quantity\": 20\n  }'\n```\n\n###### Retrieve an order by ID:\n\n```\ncurl -X 'GET' \\\n  'http://localhost:8000/orders/1' \\\n  -H 'accept: application/json'\n```\n\n###### Delete an order:\n\n```\ncurl -X 'DELETE' \\\n  'http://localhost:8000/orders/1' \\\n  -H 'accept: application/json'\n```\n\n##### 6. Docs\n\nWith FastAPI you get OpenAPI docs generated automatically if you go to path ```/docs``` \n\n```http://127.0.0.1:8000/docs```\n\n\u003cimg width=\"1477\" alt=\"Screen Shot 2023-08-03 at 10 40 58 am\" src=\"https://github.com/oracle-quickstart/fastapi-oracle-database-example/assets/39692236/3b853031-793a-4237-80c8-54a72c6f194f\"\u003e\n\n\n\n```http://127.0.0.1:8000/redoc```\n\n\u003cimg width=\"1493\" alt=\"Screen Shot 2023-08-07 at 10 36 34 am\" src=\"https://github.com/oracle-quickstart/fastapi-oracle-database-example/assets/39692236/908c3794-206b-4e41-a296-37627128f148\"\u003e\n\n## More on REST APIs for Oracle\n\nOracle Database also provides native REST APIs capabilities. To learn more, see :\n\nProduct Page : https://www.oracle.com/database/technologies/appdev/rest.html\n\nHands-on LiveLab : https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=815\n\n## Contributing\n\nThis project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide](./CONTRIBUTING.md)\n\n## Security\n\nPlease consult the [security guide](./SECURITY.md) for our responsible security vulnerability disclosure process\n\n## License\n\nCopyright (c) 2023 Oracle and/or its affiliates.\n\nReleased under the Apache License version 2.0 as shown at\n\u003chttp://www.apache.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-quickstart%2Ffastapi-oracle-database-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foracle-quickstart%2Ffastapi-oracle-database-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-quickstart%2Ffastapi-oracle-database-example/lists"}