Code Monkey home page Code Monkey logo

playground-for-python's Introduction

Appwrite's Python Playground 🎮

Appwrite playground is a simple way to explore the Appwrite API & Appwrite Python SDK. Use the source code of this repository to learn how to use the different Appwrite Python SDK features.

Work in progress

System Requirements

  • A system with Python 3+ or Docker installed.
  • An Appwrite instance.
  • An Appwrite project created in the console.
  • An Appwrite API key created in the console.

Installation

  1. Clone this repository.
  2. cd into the repository.
  3. Open the playground.py file found in the root of the cloned repository.
  4. Copy Project ID, endpoint and API key from Appwrite console into playground.py
  5. Run the playground: Python: - Install dependencies using pip pip install -r requirements.txt - Execute the command python playground.py Docker: - Execute the command docker compose up
  6. You will see the JSON response in the console.

API's Covered

  • Database

    • Create Collection
    • List Collections
    • Add Document
    • List Documents
    • Delete Document
    • Delete Collection
  • Storage

    • Create Bucket
    • List Buckets
    • Upload File
    • List Files
    • Delete File
    • Delete Bucket
  • Users

    • Create User
    • List Users
    • Delete User
  • Functions

    • Create Function
    • List Functions
    • Delete Function

Contributing

All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.

We truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the contribution guide.

Security

For security issues, kindly email us [email protected] instead of posting a public issue in GitHub.

Follow Us

Join our growing community around the world! Follow us on Twitter, Facebook Page, Facebook Group or join our Discord Server for more help, ideas and discussions.

playground-for-python's People

Contributors

abnegate avatar amuthan-tw avatar aztecrabbit avatar christyjacob4 avatar eldadfux avatar lohanidamodar avatar nibba2018 avatar pradyumnkumarpandey-cse avatar thevikj avatar trishitapingolia avatar whitebumblebee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

playground-for-python's Issues

Fixing some typos

Hey!

I just fixed some typos in the comments and docs and was just wondering if I could create a pull request. I read the CONTRIBUTING.md file in the README and I'm a little new to GitHub etiquette so I wanted to create an issue first.

Thanks!

🚀 Feature: Developer environment (Online IDE)

🔖 Feature description

Hello maintainers.
I would like to add gitpod to your repo to help beginners contribute.

  • Gitpod is an online IDE which can be launched from any GitHub page. Within seconds, Gitpod provides a fully working development environment, including a VS Code-powered IDE and a cloud-based Linux container explicitly configured for the project
  • I have seen one of your repo adopt gitpod to help new contributors in their open-source journey. It's hassle-free. You don't need to worry about dependencies not being present, since gitpod does all the heavy lifting.

I can add a badge to your repo in the CONTRIBUTING.md file similar to this one:

Contribute with Gitpod

🎤 Pitch

  • Gitpod is highly contextual, such that it opens the IDE in the correct mode depending on the context:
    • If you are looking at a particular file of a certain commit on GitHub, starting a Gitpod workspace will check out the right version and open the file you’ve been looking at in the IDE.

    • Starting a Gitpod workspace from an issue will automatically create a branch and preconfigure the commit message.

  • Once you are in the IDE, you can interact with GitHub in various ways. Besides the obvious Git integration, you can do things like commenting inline in editors, approving and even merging PRs.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

🐛 Bug Report: Error while interacting with `database`

👟 Reproduction steps

Running Create Database API
---------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
File /usr/lib/python3/dist-packages/urllib3/connection.py:174, in HTTPConnection._new_conn(self)
    173 try:
--> 174     conn = connection.create_connection(
    175         (self._dns_host, self.port), self.timeout, **extra_kw
    176     )
    178 except SocketTimeout:

File /usr/lib/python3/dist-packages/urllib3/util/connection.py:73, in create_connection(address, timeout, source_address, socket_options)
     69     return six.raise_from(
     70         LocationParseError("'%s', label empty or too long" % host), None
     71     )
---> 73 for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
     74     af, socktype, proto, canonname, sa = res

File /usr/lib/python3.11/socket.py:962, in getaddrinfo(host, port, family, type, proto, flags)
    961 addrlist = []
--> 962 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    963     af, socktype, proto, canonname, sa = res

gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:704, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    703 # Make the request on the httplib connection object.
--> 704 httplib_response = self._make_request(
    705     conn,
    706     method,
    707     url,
    708     timeout=timeout_obj,
    709     body=body,
    710     headers=headers,
    711     chunked=chunked,
    712 )
    714 # If we're going to release the connection in ``finally:``, then
    715 # the response doesn't need to know about the connection. Otherwise
    716 # it will also try to release it and we'll have a double-release
    717 # mess.

File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:387, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    386 try:
--> 387     self._validate_conn(conn)
    388 except (SocketTimeout, BaseSSLError) as e:
    389     # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1045, in HTTPSConnectionPool._validate_conn(self, conn)
   1044 if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
-> 1045     conn.connect()
   1047 if not conn.is_verified:

File /usr/lib/python3/dist-packages/urllib3/connection.py:358, in HTTPSConnection.connect(self)
    356 def connect(self):
    357     # Add certificate verification
--> 358     self.sock = conn = self._new_conn()
    359     hostname = self.host

File /usr/lib/python3/dist-packages/urllib3/connection.py:186, in HTTPConnection._new_conn(self)
    185 except SocketError as e:
--> 186     raise NewConnectionError(
    187         self, "Failed to establish a new connection: %s" % e
    188     )
    190 return conn

NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fc7358c6850>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
File /usr/lib/python3/dist-packages/requests/adapters.py:489, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    488 if not chunked:
--> 489     resp = conn.urlopen(
    490         method=request.method,
    491         url=url,
    492         body=request.body,
    493         headers=request.headers,
    494         redirect=False,
    495         assert_same_host=False,
    496         preload_content=False,
    497         decode_content=False,
    498         retries=self.max_retries,
    499         timeout=timeout,
    500     )
    502 # Send the request.
    503 else:

File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:788, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    786     e = ProtocolError("Connection aborted.", e)
--> 788 retries = retries.increment(
    789     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    790 )
    791 retries.sleep()

File /usr/lib/python3/dist-packages/urllib3/util/retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
    591 if new_retry.is_exhausted():
--> 592     raise MaxRetryError(_pool, url, error or ResponseError(cause))
    594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /v1/databases (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc7358c6850>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
File ~/.local/lib/python3.11/site-packages/appwrite/client.py:86, in Client.call(self, method, path, headers, params)
     85 try:
---> 86     response = requests.request(  # call method dynamically https://stackoverflow.com/a/4246075/2299554
     87         method=method,
     88         url=self._endpoint + path,
     89         params=self.flatten(params, stringify=stringify),
     90         data=self.flatten(data),
     91         json=json,
     92         files=files,
     93         headers=headers,
     94         verify=(not self._self_signed),
     95     )
     97     response.raise_for_status()

File /usr/lib/python3/dist-packages/requests/api.py:59, in request(method, url, **kwargs)
     58 with sessions.Session() as session:
---> 59     return session.request(method=method, url=url, **kwargs)

File /usr/lib/python3/dist-packages/requests/sessions.py:587, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    586 send_kwargs.update(settings)
--> 587 resp = self.send(prep, **send_kwargs)
    589 return resp

File /usr/lib/python3/dist-packages/requests/sessions.py:701, in Session.send(self, request, **kwargs)
    700 # Send the request
--> 701 r = adapter.send(request, **kwargs)
    703 # Total elapsed time of the request (approximately)

File /usr/lib/python3/dist-packages/requests/adapters.py:565, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    563         raise SSLError(e, request=request)
--> 565     raise ConnectionError(e, request=request)
    567 except ClosedPoolError as e:

ConnectionError: HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /v1/databases (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc7358c6850>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

AppwriteException                         Traceback (most recent call last)
Cell In [4], line 325
    322     delete_function()
    324 if __name__ == "__main__":
--> 325     run_all_tasks()
    326     p("Successfully ran playground!")

Cell In [4], line 296, in run_all_tasks()
    293 def run_all_tasks():
    294 
    295     # Databases
--> 296     create_database()
    297     create_collection()
    298     list_collections()

Cell In [4], line 46, in create_database()
     43 global database_id
     45 p("Running Create Database API")
---> 46 response = databases.create(
     47     database_id=ID.unique(),
     48     name='Movies',
     49 )
     50 database_id = response['$id']
     51 print(response)

File ~/.local/lib/python3.11/site-packages/appwrite/services/databases.py:39, in Databases.create(self, database_id, name)
     36 params['databaseId'] = database_id
     37 params['name'] = name
---> 39 return self.client.call('post', path, {
     40     'content-type': 'application/json',
     41 }, params)

File ~/.local/lib/python3.11/site-packages/appwrite/client.py:113, in Client.call(self, method, path, headers, params)
    111         raise AppwriteException(response.text, response.status_code)
    112 else:
--> 113     raise AppwriteException(e)

AppwriteException: HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /v1/databases (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc7358c6850>: Failed to establish a new connection: [Errno -2] Name or service not known'))

👍 Expected behavior

should work

👎 Actual Behavior

not working

🎲 Appwrite version

Version 0.10.x

💻 Operating system

Linux

🧱 Your Environment

everything latest and standard

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Update ReadMe

Hi, please assign me this issue. I want to make the read me more descriptive.

🐛 Bug Report: not working on `http` and only works on `https`

👟 Reproduction steps

Code I ran :

users = Users(client)
result = users.create('uiduid123', '[email protected]', 'password')
result

Error I got :

--------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
File /usr/lib/python3/dist-packages/urllib3/connection.py:174, in HTTPConnection._new_conn(self)
    173 try:
--> 174     conn = connection.create_connection(
    175         (self._dns_host, self.port), self.timeout, **extra_kw
    176     )
    178 except SocketTimeout:

File /usr/lib/python3/dist-packages/urllib3/util/connection.py:73, in create_connection(address, timeout, source_address, socket_options)
     69     return six.raise_from(
     70         LocationParseError("'%s', label empty or too long" % host), None
     71     )
---> 73 for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
     74     af, socktype, proto, canonname, sa = res

File /usr/lib/python3.11/socket.py:962, in getaddrinfo(host, port, family, type, proto, flags)
    961 addrlist = []
--> 962 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    963     af, socktype, proto, canonname, sa = res

gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:704, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    703 # Make the request on the httplib connection object.
--> 704 httplib_response = self._make_request(
    705     conn,
    706     method,
    707     url,
    708     timeout=timeout_obj,
    709     body=body,
    710     headers=headers,
    711     chunked=chunked,
    712 )
    714 # If we're going to release the connection in ``finally:``, then
    715 # the response doesn't need to know about the connection. Otherwise
    716 # it will also try to release it and we'll have a double-release
    717 # mess.

File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:387, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    386 try:
--> 387     self._validate_conn(conn)
    388 except (SocketTimeout, BaseSSLError) as e:
    389     # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1045, in HTTPSConnectionPool._validate_conn(self, conn)
   1044 if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
-> 1045     conn.connect()
   1047 if not conn.is_verified:

File /usr/lib/python3/dist-packages/urllib3/connection.py:358, in HTTPSConnection.connect(self)
    356 def connect(self):
    357     # Add certificate verification
--> 358     self.sock = conn = self._new_conn()
    359     hostname = self.host

File /usr/lib/python3/dist-packages/urllib3/connection.py:186, in HTTPConnection._new_conn(self)
    185 except SocketError as e:
--> 186     raise NewConnectionError(
    187         self, "Failed to establish a new connection: %s" % e
    188     )
    190 return conn

NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7ff06fd18690>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
File /usr/lib/python3/dist-packages/requests/adapters.py:489, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    488 if not chunked:
--> 489     resp = conn.urlopen(
    490         method=request.method,
    491         url=url,
    492         body=request.body,
    493         headers=request.headers,
    494         redirect=False,
    495         assert_same_host=False,
    496         preload_content=False,
    497         decode_content=False,
    498         retries=self.max_retries,
    499         timeout=timeout,
    500     )
    502 # Send the request.
    503 else:

File /usr/lib/python3/dist-packages/urllib3/connectionpool.py:788, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    786     e = ProtocolError("Connection aborted.", e)
--> 788 retries = retries.increment(
    789     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    790 )
    791 retries.sleep()

File /usr/lib/python3/dist-packages/urllib3/util/retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
    591 if new_retry.is_exhausted():
--> 592     raise MaxRetryError(_pool, url, error or ResponseError(cause))
    594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /v1/users (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7ff06fd18690>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
File ~/.local/lib/python3.11/site-packages/appwrite/client.py:86, in Client.call(self, method, path, headers, params)
     85 try:
---> 86     response = requests.request(  # call method dynamically https://stackoverflow.com/a/4246075/2299554
     87         method=method,
     88         url=self._endpoint + path,
     89         params=self.flatten(params, stringify=stringify),
     90         data=self.flatten(data),
     91         json=json,
     92         files=files,
     93         headers=headers,
     94         verify=(not self._self_signed),
     95     )
     97     response.raise_for_status()

File /usr/lib/python3/dist-packages/requests/api.py:59, in request(method, url, **kwargs)
     58 with sessions.Session() as session:
---> 59     return session.request(method=method, url=url, **kwargs)

File /usr/lib/python3/dist-packages/requests/sessions.py:587, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    586 send_kwargs.update(settings)
--> 587 resp = self.send(prep, **send_kwargs)
    589 return resp

File /usr/lib/python3/dist-packages/requests/sessions.py:701, in Session.send(self, request, **kwargs)
    700 # Send the request
--> 701 r = adapter.send(request, **kwargs)
    703 # Total elapsed time of the request (approximately)

File /usr/lib/python3/dist-packages/requests/adapters.py:565, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    563         raise SSLError(e, request=request)
--> 565     raise ConnectionError(e, request=request)
    567 except ClosedPoolError as e:

ConnectionError: HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /v1/users (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7ff06fd18690>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

AppwriteException                         Traceback (most recent call last)
Cell In [5], line 2
      1 users = Users(client)
----> 2 result = users.create('uiduid123', '[email protected]', 'password')
      3 result

File ~/.local/lib/python3.11/site-packages/appwrite/services/users.py:39, in Users.create(self, user_id, email, phone, password, name)
     36 params['password'] = password
     37 params['name'] = name
---> 39 return self.client.call('post', path, {
     40     'content-type': 'application/json',
     41 }, params)

File ~/.local/lib/python3.11/site-packages/appwrite/client.py:113, in Client.call(self, method, path, headers, params)
    111         raise AppwriteException(response.text, response.status_code)
    112 else:
--> 113     raise AppwriteException(e)

AppwriteException: HTTPSConnectionPool(host='hostname', port=443): Max retries exceeded with url: /v1/users (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7ff06fd18690>: Failed to establish a new connection: [Errno -2] Name or service not known'))

👍 Expected behavior

Should make a new user

👎 Actual Behavior

not making a new user and giving error

🎲 Appwrite version

Version 0.10.x

💻 Operating system

Linux

🧱 Your Environment

Everything standard and latest

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Upgrade our issue templates to use GitHub issue forms ✍️

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them 🤯.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? 🤔 Let us know, and we will assign it to you 😊

Happy Appwriting!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.