{"library":"postgrest","code":"import asyncio\nimport os\nfrom postgrest import AsyncPostgrestClient\n\n# Replace with your PostgREST URL and (optional) API key\nPOSTGREST_URL = os.environ.get('POSTGREST_URL', 'http://localhost:3000')\n# BEARER_TOKEN = os.environ.get('POSTGREST_TOKEN', 'YOUR_API_KEY') # Optional, if authentication is required\n\nasync def main():\n    # headers = {'Authorization': f'Bearer {BEARER_TOKEN}'} if BEARER_TOKEN else {}\n    headers = {}\n\n    async with AsyncPostgrestClient(POSTGREST_URL, headers=headers) as client:\n        try:\n            # Example: Insert data\n            print('Inserting a new country...')\n            insert_result = await client.from_('countries').insert({'name': 'Exampleland', 'capital': 'Example City'}).execute()\n            print(f'Insert successful: {insert_result.data}')\n\n            # Example: Read data\n            print('Fetching countries...')\n            response = await client.from_('countries').select('id', 'name', 'capital').limit(5).execute()\n            print('Fetched countries:')\n            for country in response.data:\n                print(f\"  ID: {country['id']}, Name: {country['name']}, Capital: {country['capital']}\")\n\n            # Example: Update data\n            print('Updating Exampleland...')\n            update_result = await client.from_('countries').update({'capital': 'New Example City'}).eq('name', 'Exampleland').execute()\n            print(f'Update successful: {update_result.data}')\n            \n            # Example: Delete data\n            print('Deleting Exampleland...')\n            delete_result = await client.from_('countries').delete().eq('name', 'Exampleland').execute()\n            print(f'Delete successful: {delete_result.data}')\n\n        except Exception as e:\n            print(f\"An error occurred: {e}\")\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to initialize an `AsyncPostgrestClient`, perform basic CRUD (Create, Read, Update, Delete) operations, and call `execute()` to send requests. It assumes a running PostgREST server accessible at `POSTGREST_URL` with a 'countries' table. The example also shows how to optionally include authentication headers.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}