Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • F FastAPI
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Sitemule
  • Public
  • workshops
  • open source on IBM i
  • FastAPI
  • Wiki
  • Part 3b. Connecting my first service

Part 3b. Connecting my first service · Changes

Page history
Update Part 3b. Connecting my first service authored Oct 30, 2021 by Jens Melgard Churchill's avatar Jens Melgard Churchill
Hide whitespace changes
Inline Side-by-side
Part-3b.-Connecting-my-first-service.md
View page @ 77106dda
......@@ -94,50 +94,6 @@ def read_item(query: Optional[str] = Form(...)):
Save, and press **F5** in vim, just in case.
I get an error here, namely that the driver doesn't exist.
```
Traceback (most recent call last):
File "/home/dmousr001/fastapi/.venv/bin/hypercorn", line 8, in <module>
sys.exit(main())
File "/home/dmousr001/fastapi/.venv/lib/python3.9/site-packages/hypercorn/__main__.py", line 267, in main
run(config)
File "/home/dmousr001/fastapi/.venv/lib/python3.9/site-packages/hypercorn/run.py", line 34, in run
worker_func(config)
File "/home/dmousr001/fastapi/.venv/lib/python3.9/site-packages/hypercorn/asyncio/run.py", line 178, in asyncio_worker
app = load_application(config.application_path)
File "/home/dmousr001/fastapi/.venv/lib/python3.9/site-packages/hypercorn/utils.py", line 110, in load_application
module = import_module(import_name)
File "/QOpenSys/pkgs/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/dmousr001/fastapi/main.py", line 9, in <module>
from api_router import router as apis
File "/home/dmousr001/fastapi/api_router.py", line 19, in <module>
from db2 import getProducts
File "/home/dmousr001/fastapi/db2.py", line 12, in <module>
__internalConn = pyodbc.connect(
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'IBM i Access ODBC Driver' : file not found (0) (SQLDriverConnect)")
```
Seems IBM has renamed their driver, so we need to change the name.
Exit vim `:q`
Start a Python shell `python`, and lets investigate...
From the shell, we `import pyodbc` - the we `print(pyodbc.drivers())`
Take note, the drivername is ``
Type `quit()` to exit python, and return to `vim db2.py` to change the driver name.
## Good things to those who wait.
Let's test if that works, switch to your browser, and head into the docs endpoint...
\ No newline at end of file
Clone repository
  • Part 1a. My first service
  • Part 1b. Testing my first service
  • Part 2a. Extending my first service
  • Part 2b. Organise my first service
  • Part 3a. Review my first service
  • Part 3b. Connecting my first service
  • Home