Can't find table in different schema #1144
Replies: 7 comments 7 replies
-
When you refer to a table in this third party library, you have to either share the from my_third_party_library.model import users_table
class Account(Base):
__tablename__ = 'account'
id = Column(UUID, ForeignKey(users_table.c.id, ondelete="CASCADE"), primary_key=True) |
Beta Was this translation helpful? Give feedback.
-
I also am wondering how to do this. @clarky2233 Did you ever figure out how to do this? If so do you have some example code I could grok? |
Beta Was this translation helpful? Give feedback.
-
I'm planning to use SQLAlchemy and Supabase. Just curious, is there any reason to use alembic instead of the Supabase CLI's DB migrations functionality? |
Beta Was this translation helpful? Give feedback.
-
I actually gave up trying to use SQLAlchemy and Alembic and just used
prisma. You can ask CharGPT to convert your models and it does an ok enough
job but still usually needs manual massaging. Since it’s a react app
anyways it seems to make more sense. I still prefer SQLAlchemy however.
On Sun, May 14, 2023 at 8:54 AM Alex Leonov ***@***.***> wrote:
I'm planning to use SQLAlchemy and Supabase. Just curious, is there any
reason to use alembic instead of the Supabase CLI's DB migrations
functionality?
—
Reply to this email directly, view it on GitHub
<#1144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAW7FS3COODYUGHZUSSFA73XGDPZZANCNFSM6AAAAAATD4GOH4>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
All Good Things,
Seth Rutner
|
Beta Was this translation helpful? Give feedback.
-
I wanted to use Python but the edge functions do not allow you to use
Python AFAIK. How are you using Python, do you have some code running
outside of Supabase?
…On Sun, May 14, 2023 at 10:50 AM Alex Leonov ***@***.***> wrote:
Hmm, I guess this is assuming that you're not using Python and opting to
use JS/TS on the server instead? I can't use Prisma because my server-side
code is Python with FastAPI.
—
Reply to this email directly, view it on GitHub
<#1144 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAW7FSYB4TFGINZY2PXFDHTXGELN7ANCNFSM6AAAAAATD4GOH4>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
All Good Things,
Seth Rutner
|
Beta Was this translation helpful? Give feedback.
-
A bit late @clarky2233 but this youtube video helped me solve this exact issue (referencing a table on the "auth" schema from supabase). The users table from the auth schema has a lot of content, so to automatically generate the Model in SQLAlchemy, I ran sqlacodegen (someone in this thread referenced it). It automatically built the Users model and referenced it as a table from the auth schema and I just copied and pasted it. That was it. All I had to do then was change my ForeignKey from "auth.users.id" to reference directly the object of the model I just created (or sqlacodegen created and I just copied) like this: |
Beta Was this translation helpful? Give feedback.
-
the table users in schemas auth isn't a model, it just database, so you can make a FK from a model to a database. Ex:
So you can make a FK to auth.users after upgrade |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using supabase to host my postgres database, which comes with a pre-made schema called 'auth' to handle authenticated users. I am trying to reference a table in this schema but I am getting a
sqlalchemy.exc.NoReferencedTableError
error.However, if I add an
include_name
function to the env.py file I can see the auth.users table. So I don't know why it is giving me this error?Below is my table definition:
And here is what is printed by
include_name
when I run autogenerate:Beta Was this translation helpful? Give feedback.
All reactions