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

Cannot set options when instantiating Supabase client #516

Closed
d-c-turner opened this issue Aug 8, 2023 · 1 comment
Closed

Cannot set options when instantiating Supabase client #516

d-c-turner opened this issue Aug 8, 2023 · 1 comment

Comments

@d-c-turner
Copy link

Describe the bug
Cannot set options (such as schema, timeout etc.) for Supabase client in terminal or Jupyter notebook.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Supabase client in a new .py file using your database URL and service role key, and attempt to set an option:
supabase: Client = create_client(url, key, {"schema": "some_other_schema"})

``
2. Attempt to run your .py file in the terminal, VSCode debug mode or a Jupyter notebook.
3. It will throw the error: AttributeError: 'dict' object has no attribute 'headers'

Expected behavior
Successful declaration of a new Supabase client, allowing the user to fetch or insert new data into, for example, a table on a different schema to 'public'.

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS
@d-c-turner
Copy link
Author

Closing my own issue - this is a documentation problem, not a library problem.

The docs say that the correct way to instantiate a new client with options is like so:

import os
from supabase import create_client, Client

url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_KEY")
supabase: Client = create_client(url, key, options={'timeout': 10})

However, checking closed issues (which I really should have done before opening this one), reveals that options must be set using ClientOptions():

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

opts = ClientOptions().replace(schema="some_other_schema")

url = os.getenv("SUPABASE_URL")
key = os.getenv("SUPABASE_KEY")

supabase: Client = create_client(url, key, opts)

@d-c-turner d-c-turner closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2023
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

1 participant