Closed justintime closed 7 months ago
What file contains the base model class, and what is it named?
My original post had some bad formatting, I updated it to make the structure clearer.
To answer your question, my models.py contains my Base class:
class Base(DeclarativeBase):
pass
What's the exact command you ran and the output?
(venv) justine@mbp python % paracelsus graph db.models:Base
Traceback (most recent call last):
File "/Users/justine/development/project-code/python/venv/bin/paracelsus", line 8, in <module>
sys.exit(app())
^^^^^
File "/Users/justine/development/project-code/python/venv/lib/python3.12/site-packages/paracelsus/cli.py", line 94, in graph
get_graph_string(
File "/Users/justine/development/project-code/python/venv/lib/python3.12/site-packages/paracelsus/cli.py", line 44, in get_graph_string
base_module = importlib.import_module(module_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'db'
(venv) justine@mbp python % ls db
__init__.py __pycache__ models.py
Thanks for reporting!
This could be resolved with the python-dir
option, like so:
paracelsus graph db.models:Base --python-dir=.
That being said I think it makes sense to add the current working directory there automatically, so pull request #6 added that small change in. If you upgrade to the latest release your command should work without any changes.
Excellent, thanks so much. I can verify 0.3.0 works for me!
I have a python setup where I've got some relatively simple scripts that interact with a fairly complex database that I've wrapped with SQLAlchemy. Here's the structure:
No matter what I've tried to pass to
paracelsus
on the command line, I can't get it to load my base class. Any ideas on what I can do to use this tool?