Skip to main content

Python Client API for Space Cloud

Installation

$ pip install space-api-py

Documentation

The complete documentation can be found here.

Quick Start

Create Client Instance

from space_api import API, AND, OR, COND

api = API('demo-project', 'localhost:8081')

# For MongoDB
db = api.mongo()

# For PostgresQL
db = api.postgres()

# For MySQL
db = api.my_sql()

Note: Multiple databases may be used simultaneously.

Insert a document into the database

response = db.insert('books').doc({"name": "MyBook", "author": "John Doe"}).apply()
if response.status == 200:
    # Record successfully inserted
    print("Success")
else:
    # An error occurred
    print(response.error)

Query documents in database

response = db.get('books').sort('-author').apply()
if response.status == 200:
    # We got some result
    print(response.result)
else:
    # An error occurred
    print(response.error)

Update documents in database

response = db.update_one('books').where(COND("author", "==", "some_author")).set({"author": "myself"}).apply()
if response.status == 200:
    # Record successfully updated
    print("Success")
else:
    # An error occurred
    print(response.error)

Delete documents in database

response = db.delete('books').where(COND('name', '!=', 'Book_name')).apply()
if response.status == 200:
    # Record successfully deleted
    print("Success")
else:
    # An error occurred
    print(response.error)

Batch Multiple Requests in database

b = db.begin_batch()
b.add(db.insert('books').doc({"name": "MyBook", "author": "John Doe"}))
b.add(db.insert('books').docs([{"name": "BookName"}, {"name": "BookName"}]))
b.add(db.delete('books').where(COND('name', '!=', 'Book_name')))
response = b.apply()
if response.status == 200:
    # Record successfully made the changes
    print("Success")
else:
    # An error occurred
    print(response.error)

Call functions directly (Function as a Service)

response = api.call('test_engine', 'test_func', 'params')
print(response)

User Management - Sign In

response = db.sign_in("user_email", "user_password")
if response.status == 200:
    print(response.result)
else:
    print(response.error)

User Management - Sign Up

response = db.sign_up("user_email", "user_name", "user_password", "user_role")
if response.status == 200:
    print(response.result)
else:
    print(response.error)

User Management - View Profile

response = db.profile("user_id")
if response.status == 200:
    print(response.result)
else:
    print(response.error)

User Management - View All Profiles

response = db.profiles()
if response.status == 200:
    print(response.result)
else:
    print(response.error)

User Management - Edit Profile

response = db.edit_profile("user_id", email="new_email", name="new_name", password="new_password")
if response.status == 200:
    print(response.result)
else:
    print(response.error)

Authors

Aliabbas Merchant - Initial work

License

Copyright 2019 Space Up Technologies

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for space-api-py 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for space-api-py 0.9.1
File Size Uploaded Provenance Actions
space-api-py-0.9.1.tar.gz 24.1 kB Without provenance Details for space-api-py-0.9.1.tar.gz

Release files / space-api-py-0.9.1.tar.gz

Download URL space-api-py-0.9.1.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c56c7de1bf26c75eba22ab259597be1843d66c9444449386b6d35018817038ed
BLAKE2b-256 checksum
How to use checksums
940b3e707f057f36350245f57fb3fd7e1f1cf2bda41363f1e88d5b750e42df65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

Security for space-api-py 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page