snowflake-ice-pick


Namesnowflake-ice-pick JSON
Version 0.0.6 PyPI version JSON
download
home_page
SummarySnowpark extension to cover additional objects and higher level functions
upload_time2024-02-15 00:45:24
maintainer
docs_urlNone
authorPreston Blackburn
requires_python>=3.8.0
licenseThe MIT License (MIT) Copyright (c) 2023 Preston Blackburn Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords snowflake metadata utils
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![ice pick logo](https://github.com/PrestonBlackburn/ice_pick/blob/main/docs/img/ice_pick_logo_mountain.png?raw=true)

# Ice Pick
[![PyPI Latest Release](https://img.shields.io/pypi/v/snowflake-ice-pick.svg)](https://pypi.org/project/snowflake-ice-pick/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/PrestonBlackburn/ice_pick/blob/main/LICENSE)
[![Codestyle Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

**Ice Pick** is a Python package that provides utilities for common operations done on a Snowflake warehouse. Operations range from getting Snowflake object ddl, getting table statistics, and returning account level information.

Many utilities can be automatically packaged and deployed as stored procedures, so they can be executed natively in Snowflake.


## Main Features

Interact with schema objects with a Snowpark like interface.  
In this initial development two data classes are available: `SchemaObject` and `SchemaObjectFilter`. The `SchemaObject` allows you to interact and retrieve information on the schema object, such as ddl, description, and grants.  
<br/>
The `SchemaObjectFilter` allows you to quickly return and inspect many schema objects. With the `SchemaObjectFilter` you can filter on specific databases, schemas, objects or object types using regex. Alternatively you can specify ignore filters to return all objects not in the filter.  
<br/>


## Getting Started

### Read the docs: https://ice-pick.readthedocs.io/en/latest/

<br/>
<br/>

### install the library
```bash
python -m pip install snowflake-ice-pick
```

### create a snowpark session
Ice pick extends the session to add the additional functionality
```python
from snowflake.snowpark import Session
from ice_pick import extend_session

connection_parameters = {
  "account": "<your snowflake account>",
  "user": "<your snowflake user>",
  "password": "<your snowflake password>",
  "role": "<snowflake user role>",
  "warehouse": "<snowflake warehouse>",
  "database": "<snowflake database>",
  "schema": "<snowflake schema>"
}

session = extend_session(Session).builder.configs(connection_parameters).create()
```
## Example Usage
### Return the ddl, description, and grants for a schema object 
```python
from ice_pick import SchemaObject

table_obj = session.create_schema_object('TEST', 'SCHEMA_1', 'CUSTOMER', 'TABLE')

# Get the ddl for the specified object
ddl = table_obj.get_ddl()

# Get the description of the object
description = table_obj.get_description()

# Get the grants on the object
grants_on = table_obj.get_grants_on()

# Grant the object to a role with permissions specified in a list
grant = table_obj.grant(["SELECT"], "PUBLIC")
```


### Return bulk ddl for tables and procedures in the TEST database and the databases matching the TEST_* pattern 
```python
from ice_pick import SchemaObject, SchemaObjectFilter

# create the fitler, where "*" are wildcards (regex supported)
obj_filter = session.create_schema_object_filter(
                ["TEST", "TEST_*"],        # databases
                [".*"],                    # schemas
                [".*"],                    # object names
                ["tables", "Procedures"]   # object types
            )

# return the schema objects based on the filter
schema_object_list = sp_filter.return_schema_objects()

# Get the ddl for the returned schema objects
ddl_list = [schema_obj.get_ddl() for schema_obj in schema_object_list]
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "snowflake-ice-pick",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "",
    "keywords": "snowflake,metadata,utils",
    "author": "Preston Blackburn",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/50/b1/516ebac7df7c058c38aec390c5c16dee768ba47d9a566edec127eaef0b09/snowflake_ice_pick-0.0.6.tar.gz",
    "platform": null,
    "description": "![ice pick logo](https://github.com/PrestonBlackburn/ice_pick/blob/main/docs/img/ice_pick_logo_mountain.png?raw=true)\r\n\r\n# Ice Pick\r\n[![PyPI Latest Release](https://img.shields.io/pypi/v/snowflake-ice-pick.svg)](https://pypi.org/project/snowflake-ice-pick/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/PrestonBlackburn/ice_pick/blob/main/LICENSE)\r\n[![Codestyle Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n\r\n**Ice Pick** is a Python package that provides utilities for common operations done on a Snowflake warehouse. Operations range from getting Snowflake object ddl, getting table statistics, and returning account level information.\r\n\r\nMany utilities can be automatically packaged and deployed as stored procedures, so they can be executed natively in Snowflake.\r\n\r\n\r\n## Main Features\r\n\r\nInteract with schema objects with a Snowpark like interface.  \r\nIn this initial development two data classes are available: `SchemaObject` and `SchemaObjectFilter`. The `SchemaObject` allows you to interact and retrieve information on the schema object, such as ddl, description, and grants.  \r\n<br/>\r\nThe `SchemaObjectFilter` allows you to quickly return and inspect many schema objects. With the `SchemaObjectFilter` you can filter on specific databases, schemas, objects or object types using regex. Alternatively you can specify ignore filters to return all objects not in the filter.  \r\n<br/>\r\n\r\n\r\n## Getting Started\r\n\r\n### Read the docs: https://ice-pick.readthedocs.io/en/latest/\r\n\r\n<br/>\r\n<br/>\r\n\r\n### install the library\r\n```bash\r\npython -m pip install snowflake-ice-pick\r\n```\r\n\r\n### create a snowpark session\r\nIce pick extends the session to add the additional functionality\r\n```python\r\nfrom snowflake.snowpark import Session\r\nfrom ice_pick import extend_session\r\n\r\nconnection_parameters = {\r\n  \"account\": \"<your snowflake account>\",\r\n  \"user\": \"<your snowflake user>\",\r\n  \"password\": \"<your snowflake password>\",\r\n  \"role\": \"<snowflake user role>\",\r\n  \"warehouse\": \"<snowflake warehouse>\",\r\n  \"database\": \"<snowflake database>\",\r\n  \"schema\": \"<snowflake schema>\"\r\n}\r\n\r\nsession = extend_session(Session).builder.configs(connection_parameters).create()\r\n```\r\n## Example Usage\r\n### Return the ddl, description, and grants for a schema object \r\n```python\r\nfrom ice_pick import SchemaObject\r\n\r\ntable_obj = session.create_schema_object('TEST', 'SCHEMA_1', 'CUSTOMER', 'TABLE')\r\n\r\n# Get the ddl for the specified object\r\nddl = table_obj.get_ddl()\r\n\r\n# Get the description of the object\r\ndescription = table_obj.get_description()\r\n\r\n# Get the grants on the object\r\ngrants_on = table_obj.get_grants_on()\r\n\r\n# Grant the object to a role with permissions specified in a list\r\ngrant = table_obj.grant([\"SELECT\"], \"PUBLIC\")\r\n```\r\n\r\n\r\n### Return bulk ddl for tables and procedures in the TEST database and the databases matching the TEST_* pattern \r\n```python\r\nfrom ice_pick import SchemaObject, SchemaObjectFilter\r\n\r\n# create the fitler, where \"*\" are wildcards (regex supported)\r\nobj_filter = session.create_schema_object_filter(\r\n                [\"TEST\", \"TEST_*\"],        # databases\r\n                [\".*\"],                    # schemas\r\n                [\".*\"],                    # object names\r\n                [\"tables\", \"Procedures\"]   # object types\r\n            )\r\n\r\n# return the schema objects based on the filter\r\nschema_object_list = sp_filter.return_schema_objects()\r\n\r\n# Get the ddl for the returned schema objects\r\nddl_list = [schema_obj.get_ddl() for schema_obj in schema_object_list]\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2023 Preston Blackburn  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Snowpark extension to cover additional objects and higher level functions",
    "version": "0.0.6",
    "project_urls": {
        "Homepage": "https://github.com/PrestonBlackburn/ice_pick"
    },
    "split_keywords": [
        "snowflake",
        "metadata",
        "utils"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b189c8eb13c11aa0fd0369ae9f3ec1904c8425e961754040a17c5d20a4ec443",
                "md5": "830bc2e67df0cf2e3a4cef79c89859a0",
                "sha256": "5cdc54d4a5bb97205e68742762cbc8c9c8e62d5a81a00aea3c5bd5c5b1b5df17"
            },
            "downloads": -1,
            "filename": "snowflake_ice_pick-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "830bc2e67df0cf2e3a4cef79c89859a0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 23784,
            "upload_time": "2024-02-15T00:45:22",
            "upload_time_iso_8601": "2024-02-15T00:45:22.184472Z",
            "url": "https://files.pythonhosted.org/packages/3b/18/9c8eb13c11aa0fd0369ae9f3ec1904c8425e961754040a17c5d20a4ec443/snowflake_ice_pick-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50b1516ebac7df7c058c38aec390c5c16dee768ba47d9a566edec127eaef0b09",
                "md5": "af578c826b39687da83d18f3975d7a5e",
                "sha256": "6ecc3d0eb2e19dc1f6e6be8596c6f1bb986f0b2dac7c8067077c204d860ac9c6"
            },
            "downloads": -1,
            "filename": "snowflake_ice_pick-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "af578c826b39687da83d18f3975d7a5e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 22854,
            "upload_time": "2024-02-15T00:45:24",
            "upload_time_iso_8601": "2024-02-15T00:45:24.364387Z",
            "url": "https://files.pythonhosted.org/packages/50/b1/516ebac7df7c058c38aec390c5c16dee768ba47d9a566edec127eaef0b09/snowflake_ice_pick-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-15 00:45:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PrestonBlackburn",
    "github_project": "ice_pick",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "snowflake-ice-pick"
}
        
Elapsed time: 0.22160s