You need to use this: https://appwrite.io/docs/server/databases?sdk=python-default#databasesListDocuments
[SOLVED] Python cloud function failing with Internal runtime error
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
i am inserting into a collection the session id and a time i wish for it to be deleted by the cloud function. It is so because i have a remember me checkbox on my ui. So i do need to create an api key
it depends on the permissions on the collection and document
Rank 3: Container
ok for now i put any on create and delete
Rank 3: Container
@Steven i noticed i was missing some params but for now here is the error i get after fixing An error occurred: HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: /v1/databases/64a671fb266768330926/collections/64cbca90100c2734a432/documents (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff84d91a90>: Failed to establish a new connection: [Errno 111] Connection refused'))
Rank 3: Container
i guess since the function are inside a container they cant point to the hoost localhost , ill try my ip
Rank 3: Container
@Steven does appwrite cloud functions support env variables ? if so how can i refer to them in code ?
Did you read the docs on functions?
Rank 3: Container
@Steven Not entirely no let me get back to it then
Short answer is we have function variables rather than environment variables in the current version of functions
Rank 3: Container
@Steven ok let me comb the docs for it
Rank 3: Container
@Steven i managed to run it and now i am stuck with a permission error An error occurred: app.649338b1262c3cbe564c@service.192.168.1.6 (role: applications) missing scope (account) i gave all scope to my api key though
Rank 3: Container
i think this snippet is the culprit # Delete the session account = Account(client) delete_response = account.delete_session(session_id) print(delete_response)
You should be using the users API
Rank 3: Container
@Steven with a JWT, will it work since ther is no user connected to trigger this function ? it is supposed to run with CRON automatically
If a user isn't triggering the function, you won't have a JWT token 🧐
Rank 3: Container
@Steven indeed so how do i do the session deleting then ? i though i had to set up an API KEY for such a maintenance use case
Use the users API
Rank 3: Container
@Steven sorry ...i confused both as Accounts ...
Rank 3: Container
@Steven Let me revert as soon as i come back
Rank 3: Container
@Steven It is all good now i fixed it thanks to your guidance.
Rank 3: Container
[SOLVED] Python cloud function failing with Internal runtime error
Rank 1: Thread
is it possible to return json data in the "message" field ?
yes. if you still need help, please create a new #channel post.
Rank 1: Thread
ok thanks