Skip to content

Revised SQLAlchemy Quickstart guide #95

Merged
unatarajan merged 1 commit intomainfrom
feat/fastapi-sqlalchemy-quickstart
Aug 28, 2024
Merged

Revised SQLAlchemy Quickstart guide #95
unatarajan merged 1 commit intomainfrom
feat/fastapi-sqlalchemy-quickstart

Conversation

@unatarajan
Copy link
Copy Markdown
Contributor

Overview / Task

  • Bug
  • Feature

Description

  • Removed unnecessary code/ explanations in SQLAlchemy Quickstart.

Feature Validation / Bug Reproduction Steps

  1. From the website repo, npm run dev-docs-website.
  2. Load the localhost link in browser: http://localhost:4321/docs/quick-start-sqlalchemy-orm.

@unatarajan unatarajan merged commit e00e9f6 into main Aug 28, 2024
@unatarajan unatarajan deleted the feat/fastapi-sqlalchemy-quickstart branch August 28, 2024 20:34
@unatarajan unatarajan mentioned this pull request Aug 28, 2024
2 tasks
Comment thread sqlite-cloud/quick-start-fastapi-sqlalchemy.mdx
@danielebriggi
Copy link
Copy Markdown
Member

You can also remove the troubleshooting part. I followed your quickstart, it worked and there was no error. Actually I tried to replicate the error with the older version of sqlitecloud and python 3.11 but I wasn't able. Anyway, it works :D

@unatarajan
Copy link
Copy Markdown
Contributor Author

I re-ran the app and got the AttributeError on first run. After restarting my IDE (VSCode) it ran fine.

% uvicorn fastapi_sqlc_app.main:app --reload
INFO:     Will watch for changes in these directories: ['/Users/upasananatarajan/Desktop/sqlalchemy-quickstart']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [6634] using WatchFiles
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "/opt/homebrew/lib/python3.11/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/opt/homebrew/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/opt/homebrew/lib/python3.11/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/opt/homebrew/lib/python3.11/site-packages/uvicorn/config.py", line 434, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/upasananatarajan/Desktop/sqlalchemy-quickstart/fastapi_sqlc_app/main.py", line 1, in <module>
    from .database import SessionLocal
  File "/Users/upasananatarajan/Desktop/sqlalchemy-quickstart/fastapi_sqlc_app/database.py", line 5, in <module>
    engine = create_engine('sqlitecloud://chtwalrwiz.sqlite.cloud:8860/chinook.sqlite?apikey=lEN1TsCrDYlEFYia7VSjtme8HTFV3aHbXDy7rRBXEhM')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in create_engine
  File "/opt/homebrew/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 612, in create_engine
    dialect = dialect_cls(**dialect_args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in __init__
  File "/opt/homebrew/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/base.py", line 2004, in __init__
    if self.dbapi.sqlite_version_info < (3, 7, 16):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'sqlitecloud.dbapi2' has no attribute 'sqlite_version_info'

@unatarajan
Copy link
Copy Markdown
Contributor Author

unatarajan commented Sep 4, 2024

Latest merged PR qualifying why I used FastAPI in the quickstart demo'ing SQLAlchemy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants