https://supabase.com/ logo
Join Discord
Powered by
# python
  • a

    anand

    10/26/2021, 5:37 AM
    made PRs to postgrest-py to add proper sync support, and to add some pre-commit config
  • a

    anand

    10/26/2021, 6:17 AM
    @User or @User , take a look when you can ☝️
  • j

    J0

    10/26/2021, 5:49 PM
    ack
  • j

    J0

    10/26/2021, 5:50 PM
    No, it is on the roadmap though
  • j

    J0

    10/26/2021, 5:50 PM
    Noted, will take a look
  • a

    anand

    10/26/2021, 5:52 PM
    😆 I'm on a bit of a PR spree here
  • t

    Tito

    10/26/2021, 8:36 PM
    I am trying to delete a record using supabase-py:
    Copy code
    supabase.table('project_images').delete().filter(
                                                    'project_id', 'eq', project_id).execute()
    and I am receiving:
    Copy code
    2021-10-26 17:06:41,402:ERROR - Traceback (most recent call last):
      File "/Users/titogarrido/Documents/Projetos/paint3/minination/minination-image-api/./main.py", line 363, in delete_project
        supabase.table('project_images').delete().filter(
      File "/Users/titogarrido/Documents/Projetos/paint3/minination/minination-image-api/venv/lib/python3.9/site-packages/supabase/lib/query_builder.py", line 33, in _execute_monkey_patch
        "data": response.json(),
      File "/Users/titogarrido/Documents/Projetos/paint3/minination/minination-image-api/venv/lib/python3.9/site-packages/requests/models.py", line 900, in json
        return complexjson.loads(self.text, **kwargs)
      File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
        return _default_decoder.decode(s)
      File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    but I can't understand what I did wrong on this call... any clue?
  • t

    Tito

    10/26/2021, 8:45 PM
    seems that there is an issue open: https://github.com/supabase-community/supabase-py/issues/22
  • d

    dreinon

    10/27/2021, 12:03 AM
    I would try to use the eq filter directly instead
  • d

    dreinon

    10/27/2021, 12:04 AM
    @Tito
    supabase.table('project_images').delete().eq('project_id', str(project_id)).execute()
  • d

    dreinon

    10/27/2021, 2:04 AM
    @anand postgrest-py PR reviewed
  • a

    anand

    10/27/2021, 4:36 AM
    changes made
  • a

    anand

    10/27/2021, 4:38 AM
    code duplication is reduced via inheriting from a base client class
  • a

    anand

    10/27/2021, 4:38 AM
    and honestly, adding unasync to recreate just one single method seems unnecessarily excessive
  • d

    Deleted User

    10/27/2021, 5:19 AM
    I see better auto-generated duplicated code than having an execute method that is synchronous and asynchronous at the same time. Because to use it without mypy showing an error for awaiting something that is not always awaitable, a cast would have to be performed whenever the execute method is used.
  • a

    anand

    10/27/2021, 6:57 AM
    fair enough
  • d

    dreinon

    10/27/2021, 9:22 AM
    does unasync preserve all types?
  • d

    dreinon

    10/27/2021, 9:22 AM
    @Deleted User
  • a

    anand

    10/27/2021, 11:24 AM
    I think it will
  • a

    anand

    10/27/2021, 11:24 AM
    It'll just not touch the annotations is what I inferred from reading about it
  • d

    dreinon

    10/27/2021, 11:37 AM
    Okay, let's wait for leyniers PR to see how well it does, or if you think you can branch your current one you made a PR of and use unasync there, just so we don't wait for leynier. However you feel like depending on how busy you are 🙂
  • d

    Deleted User

    10/27/2021, 12:35 PM
    Ok, today later I will do a little PR so you can see unasync in action
  • d

    dreinon

    10/27/2021, 3:06 PM
    thanks!
  • a

    anand

    10/28/2021, 1:42 PM
    uhm, i'm quite sure that's a scam link. mods should probably delete that it's gone now
  • s

    SSardorf

    11/02/2021, 7:12 AM
    Hey - Just to be sure. The python client is not ready for production scale services, right?
  • a

    anand

    11/02/2021, 1:27 PM
    Yeah I wouldn't use it just yet in anything critical. Works being done on it pretty quickly though!
  • s

    SSardorf

    11/02/2021, 3:20 PM
    Good - Looking forward to using it in the future!
  • j

    J0

    11/02/2021, 5:47 PM
    Nope, anand is right. The client is not ready for production use at the moment. Do look out for updates w.r.t progress on launch week though 🙂
  • m

    Mattyfaz

    11/05/2021, 12:24 AM
    What is the best method to get only the last row from a table using python? Using the python client I tried to copy what was provided for JS, by doing something like:
    Copy code
    python
    data = supabase.table("test").select("*").order('id', { "ascending": False }).limit(1).execute()
    But no luck (works when I remove the
    .order()
    ).
  • a

    anand

    11/05/2021, 4:17 AM
    .order
    takes different parameters in postgrest-py I think; to get it in descending order you'd do
    .order('id', desc=True)
1...678...19Latest