Add Space Cloud to your Python project
Follow this guide to use Space Cloud APIs in your python app.
Step 1: Install Space Cloud API
Install via pip:
$ pip install space-api-py
Step 2: Create a Client instance
A client instance of Space Cloud will help you talk to
space-cloud binary and perform backend operations directly from the frontend.
API constructor takes two parameters:
- PROJECT_ID: Unqiue identifier of a project. It's derived by converting your project name to lowercase and replacing all spaces to hiphens. For example
- SPACECLOUDURL: This is the url of your
localhost:4128for grpc and grpc secure endpoints respectively.
localhostwith the address of your Space Cloud if you are not running it locally.
from space_api import API api = API('books-app', 'localhost:4124')
Step 3: Create a DB instance
api instance created above will help you to directly use
functions modules. However, to use
auth modules you will also need to create a
Note: You can use multiple databases in the same project. (For eg. MongoDB and MySQL)
db = api.mongo()
Note: This can also be used for any other database that is PostgreSQL compatible (For eg. CockroachDB, Yugabyte etc.)
db = api.postgres()
Note: This can also be used for any other database that is MySQL compatible (For eg. TiDB)
db = api.my_sql()
Great! Since you have initialized the
db instance you can start building apps with
space-cloud. Check out these modules to explore all that you can do with