Back

Python function to list all collections

  • 0
  • Functions
Capone
6 Apr, 2023, 16:59

Currently have this, but am getting an error saying 'Internal Runtime Error'

TypeScript
from appwrite.client import Client
from appwrite.services.databases import Databases

def main(req, res):
    client = Client()

    (client
    .set_endpoint(endpoint) 
    .set_project(id)
    .set_key(api key)
    )

    databases = Databases(client)

    result = databases.list_collections(collection_id)
    send = []

    for i in result['collections']:
        send.append(i['$id'])

    return res.json({"collections": send})
TL;DR
The code appears to be a Python function to list all collections using the Appwrite service. The user is getting an 'Internal Runtime Error' while running the code. The error might be due to missing or incorrect values for endpoints, project ID, and API key. There is no mention of a solution in the thread.
Arth
6 Apr, 2023, 18:02

can you confirm that the appwrite service is up and running?

Arth
6 Apr, 2023, 20:24

And btw, list_collections takes db Id as argument

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more