{"id":21152566,"url":"https://github.com/nimbella/nimbella-sdk-python","last_synced_at":"2025-07-09T10:32:54.314Z","repository":{"id":48347683,"uuid":"293672375","full_name":"nimbella/nimbella-sdk-python","owner":"nimbella","description":"Nimbella SDK for Python serverless functions. ","archived":false,"fork":false,"pushed_at":"2021-08-13T09:43:04.000Z","size":47,"stargazers_count":2,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-10T09:56:27.074Z","etag":null,"topics":["faas","nimbella","python","sdk","serverless"],"latest_commit_sha":null,"homepage":"https://nimbella.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nimbella.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-08T01:44:34.000Z","updated_at":"2024-01-19T10:27:40.000Z","dependencies_parsed_at":"2022-09-02T23:40:55.252Z","dependency_job_id":null,"html_url":"https://github.com/nimbella/nimbella-sdk-python","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimbella%2Fnimbella-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimbella%2Fnimbella-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimbella%2Fnimbella-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimbella%2Fnimbella-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nimbella","download_url":"https://codeload.github.com/nimbella/nimbella-sdk-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225533678,"owners_count":17484347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faas","nimbella","python","sdk","serverless"],"created_at":"2024-11-20T10:43:00.431Z","updated_at":"2024-11-20T10:43:00.942Z","avatar_url":"https://github.com/nimbella.png","language":"Python","readme":"# Nimbella SDK for Python\n\nA Python package to interact with [`nimbella.com`](https://nimbella.com) services.\n\n## Installation\n\n```\npip install nimbella\n```\n\n## Usage\n\nThis SDK provides access to the following cloud services on Nimbella.com:\n\n- [Redis](https://redis.io/)\n- [Object Storage](https://en.wikipedia.org/wiki/Object_storage)\n\n### Redis\n\nThe `nimbella.redis()` method returns a pre-configured Redis client for use in your application. See the [Redis client library documentation](https://pypi.org/project/redis/) for the methods provided.\n\n```python\nimport nimbella\n\n# Redis\nredis = nimbella.redis()\nredis.set(\"key\", \"value\")\nvalue = redis.get(\"key\")\n```\n\n### Object Storage (GCP \u0026 S3)\n\nThe `nimbella.storage()` method returns a pre-configured object storage client. This client exposes a high-level storage API (details below) - which hides the underlying storage provider implementation. The storage client is automatically configured to use the storage service for the cloud it is running on - which is [GCS](https://cloud.google.com/storage/) on GCP and [S3 on AWS](https://aws.amazon.com/s3/).\n\n```python\nimport nimbella\n\n# Storage\nbucket = nimbella.storage()\nfilename = \"test.txt\"\nfile = bucket.file(filename)\nfile.save('Expected %s contents' % filename, 'text/plain')\n```\n\nThe `nimbella.storage()` constructor takes a single parameter `web` to determine whether the storage bucket is for a website (`nimbella.storage(web=True)`) or files (`nimbella.storage()`). Website buckets can be used for store web content (e.g. HTML \u0026 JS files) to host static websites.\n\n#### Object Storage API\n\n```python\n# Storage API\nclass StorageProvider(web=False):    \n    # External bucket URL\n    @property\n    def url() -\u003e Union[str, None]:\n\n    # Configure website for web storage buckets\n    def setWebsite(mainPageSuffix, notFoundPage):\n\n    # Remove all files from the bucket (using optional prefix)    \n    def deleteFiles(force, prefix):\n\n    # Upload new file from path to bucket destination.\n    def upload(path, destination, contentType, cacheControl):\n\n    # Return storage file instance from bucket\n    def file(destination) -\u003e StorageFile:\n\n    # Return all storage files (with optional prefix) instance from bucket\n    def getFiles(prefix) -\u003e list:\n      \n# Storage File Class\nclass StorageFile():\n    # Name of the bucket file\n    @property\n    def name() -\u003e str:\n\n    # key/value pairs for provider-specific object metadata\n    @property\n    def metadata() -\u003e dict:\n\n    # does file exist?\n    def exists() -\u003e bool:\n\n    # delete file from bucket\n    def delete() -\u003e None:\n\n    # update file contents from string or bytes with content-type\n    def save(data: Union[str, bytes], contentType: str) -\u003e None:\n\n    # return file contents as bytes\n    def download() -\u003e bytes:\n\n    # return pre-signed url from file for external access\n    def signed_url(version: str, action: str, expires: int, contentType: str) -\u003e str:\n```\n\n#### Embedded SQL support\n\nYou can access embedded sql with: `sql = nimbella.esql()`\n\nAvailable methods are:\n\n\u003e `sql.exec(sql, *arg)` \n\nExcecute an `sql` statement. The statement is either a string in [SQL](https://sqlite.org/lang.html) or an id returned by `sql.prep` (a prepared statement). \n\nYou can also pass multiple additional `args`, for parametric statementns.\n\nIt returns an array of `[lastId, changedRows]`\n\nValues are significant where relevant (for insert or delete, but not for create for example).\n\nExample:\n\n```\n# single statement\nres = sql.exec(\"create table t(i int)\")\n# parametric statement\nres = sql.exec(\"insert into t(i) values(?),(?),(?)\",1,2,3)\n# returns [3,3]\n```\n\n\u003e `sql.map(sql, *args [,limit=\u003cn\u003e])`\n\nExecute an `sql` statement. The statement is either a string in [SQL](https://sqlite.org/lang.html) or an id returned by `sql.prep` (a prepared statement). \n\nYou can also pass multiple additional `args`, for parametric statementns.\n\nIt returns the result of an SQL query (like a `SELECT`) as an an array of dictionaries. Each dictionary is a record, where the keys are the fields and the values are the field values.\n\nThe optional keyword argument is the maximum number of records returned, it will limit the size of the returned array to the first `\u003cn\u003e`\n\n\nExamples:\n\n```\nsql.map(\"select * from t\")\n# returns [{\"i\":1},{\"i\":2},{\"i\":3}]\nsql.map(\"select * from t where i \u003e?\",1)\n# returns [{\"i\":2},{\"i\":3}]\nsql.map(\"select * from t where i \u003e?\",1,limit=1)\n# returns [{\"i\":2}]\n```\n\n\u003e `sql.arr(sql, *args [,limit=\u003cn\u003e])`\n\nExecute an `sql` statement. The statement is either a string in [SQL](https://sqlite.org/lang.html) or an id returned by `sql.prep` (a prepared statement). \n\nYou can also pass multiple additional `args`, for parametric statements.\n\nIt returns the result of an SQL query (like a `SELECT`) as an an array of arrays. Each array includes the field values of a record.\n\nThe optional keyword argument is the maximum number of records returned, it will limit the size of the returned array to the first `\u003cn\u003e`\n\nExamples:\n\n```\nsql.map(\"select * from t\")\n# returns [[1],[2],[3]]\nsql.map(\"select * from t where i \u003e?\",1)\n# returns [[2],[3]]\nsql.map(\"select * from t where i \u003e?\",1,limit=1)\n# returns [[2]]\n```\n\n\u003e `prep(sql)`\n\n\nYou can prepare statements to save time from precompiling.\n\n```\nins =  sql.prep(\"insert into t(i) values(?)\")\nsel = sql.prep(\"select * from t where i\u003e?\")\n```\n\nThe returned value is a number and can be used to execute the statement with `exec`, `map` and `arr`.\n\n```\n# executing statement\nres = sql.exec(ins,1)\n# executing query\nm = sql.map(sel,1,limit=1)\n```\n\nWhen you do not need any more you can close the statement running prep again with the returned value.\n\n```\n# closing prepared statements\nsql.prep(ins)\nsql.prep(sel)\n```\n\nNote that you can prepare up to 10000 statement at the same time without closing them, otherwise you will get an error `too many prepared statement`. In the unfortunate accident you fill the prepared statement cache, you can clear it with `prep(\"clean_prep_cache\")`\n\n## Support\n\nWe're always happy to help you with any issues you encounter. You may want to [join our Slack community](https://nimbella-community.slack.com/) to engage with us for a more rapid response.\n\n## License\n\nApache-2.0. See [LICENSE](LICENSE) to learn more.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimbella%2Fnimbella-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnimbella%2Fnimbella-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimbella%2Fnimbella-sdk-python/lists"}