Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In No Way can I access my custom schema #490

Closed
subhapradaholdings opened this issue Jul 9, 2023 · 4 comments
Closed

In No Way can I access my custom schema #490

subhapradaholdings opened this issue Jul 9, 2023 · 4 comments

Comments

@subhapradaholdings
Copy link

Describe the bug
I can see suggestions for supabase.schema("new_schema").table....

To Reproduce
See above

Expected behavior
Expected to call <schema_name>.<table_name>

Errors
File "xxx", line 18, in
supabase.schema()
TypeError: 'str' object is not callable

Other Info
Even if I change table name to supabase.table(f"<schema_name>.<table_name>") it only gives public.<schema_name>.<table_name>

Cant call ClientOptions() anymore (I think its no longer supported) as i have multiple tables and multiple schemas and cant fix to 1 schema.

Additional context
Please look into the issue, or suggest an alternative way. I know functions are a way but using python seems more easier than writing SQL functions.

@mardadi23
Copy link

ran into same issue which really reduces useful of this library when trying to use vecs schema. Would be great to support different schema at earliest

@anand2312
Copy link
Contributor

anand2312 commented Jul 13, 2023

You can change the schema that's queried by passing it as part of the options argument to create_client:

from supabase import create_client
from supabase.lib.client_options import ClientOptions

opts = ClientOptions().replace(schema="new_schema")
client = create_client(url, key, options=opts)
# now all queries will be run in the `new_schema` schema

Edit: I'd not noticed the part about multiple schemas - you could create one client per schema; but adding something to switch schemas after client initialization would be nice to have as well I think, let me look into it. Reopening the issue for now.

@anand2312 anand2312 reopened this Jul 13, 2023
@subhapradaholdings
Copy link
Author

That's nice but isn't there an option where i see that we can do supabase.schema("private").table("some_table")... i can see Schema suggestion on VS Code (may i know where it might be used)

@anand2312
Copy link
Contributor

The vscode suggestion is probably coming from here ; it's probably just picking up the attribute named schema.

Also I had forgotten earlier: We can switch the schema later, but that method is on the postgrest client
From supabase py you'd use this like so

from supabase import create_client
from supabase.lib.client_options import ClientOptions

opts = ClientOptions().replace(schema="new_schema")
client = create_client(url, key, options=opts)
# now all queries will be run in the `new_schema` schema

client.postgrest.schema("newest_schema")
# now all queries will be run in the `newest_schema` schema

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

No branches or pull requests

3 participants