Table with name <NAME> does not exist for ReflectModel? #67
Replies: 1 comment 2 replies
-
Hi @golgor so first, thank you so much for using edgy and for the feedback. I do really hope you enjoy. In a nutshell you pretty much nailed the differences between ReflectModel and Model. Although what in trying to understand is in the reflect model in theory if you pass the exact table name of the database you are connecting, in theory it should recognise the table. The inspectdb uses the reflect model for safety reasons, to make sure no migrations are generated. This can be indeed a bug that needs addressing but I've been using the reflect model with existing databases where I just map fields and the exact name of the table in the dB that I'm connecting and it works. Maybe a specific use case could be tested and we could address if is indeed an issue. |
Beta Was this translation helpful? Give feedback.
-
Hey,
First of all, great work with edgy. It seems to be very intuitive and it works great in VS Code with code completions etc.
I have a legacy database I want to use for data analysis and I used the edgy inspectdb and it crashed with an error:
Though, it did create the
models.py
and all of the models where generated, so I let that go. I tried to implement some code, but kept running into a weird issue. I have the following code:Running this code I keep getting an error that says
Table with the name AssetData does not exist.
and I really couldn't wrap my head around what was the issue. In tried to copy paste and modify one of the code examples and and I got that working with a SQLITE-database and some other models from the example.After a bit of migrating the code example to my other database, I noticed that one of the differences for me was that I used a
ReflectModel
and not aModel
. I tried to change this, and VOILA! It worked right away.I tried to read up on
ReflectModel
, but from what I understand it should pretty much be the exact same thing asModel
. The only difference is that ReflectModel won't create any migrations, is that right?So is there any additional configuration required for
ReflectModel
that is different from a regularModel
, or what can be the issue in this case?I also got some typing issues with Mypy with a query written as:
await AssetData.query.all().limit(10)
sayingMissing positional argument "self" in call to "all" of "QuerySet"Mypy(call-arg)
Just for some unresponsible testing I added:
in the
Manager
-class (edgy/core/db/models/
). If I now useawait AssetData.query().all().limit(10)
I don't get any typing issues, and the completions works much better. There are probably ways to make that better, just figured I could mention it.Beta Was this translation helpful? Give feedback.
All reactions