{ "info": { "author": "Nader Bedretdinov", "author_email": "php-job@mail.ru", "bugtrack_url": null, "classifiers": [], "description": "# Phouse easy work with clickhouse \n\n\nhttps://github.com/bedretdinov/phouse \n\n# for install\n```python\npip3 install git+https://github.com/bedretdinov/phouse\n```\n\n\n\n# Examples\n```python\n \n from phouse.phouse import Phouse \n \n \n # The connection will be repeat if get failed. It is need for stability your ETL scripts.\n # The script will try until get connection. try with interval 60 sec\n pd = Phouse.getConnection({\n 'host':'0.0.0.0',\n 'user':'default',\n 'password':'',\n 'database':'owox'\n })\n \n # return pandas dataframe\n df = pd.clickhouse_query(''' SELECT database, name FROM system.tables ''')\n \n # !!!! And very important things this data frame must have date column else you get error\n df['date'] = pd.to_datetime('today')\n \n # insert to the table\n df.clickhouse.append(table='new_table') # The table is created automatically\n \n # truncate table and insert\n df.clickhouse.write(table='new_table') # The table is created automatically \n \n \n # write by package\n \n from sklearn import datasets \n \n iris = datasets.load_iris() \n \n df = pd.DataFrame(iris.data, columns=iris.feature_names)\n df['date'] = pd.to_datetime('today')\n \n first = True\n buffer_size = 10\n for i in range(0,df.shape[0],buffer_size):\n item = df[i:i+buffer_size] \n if(first):\n item.clickhouse.write(table='iris_test')\n first = not first \n else:\n item.clickhouse.append(table='iris_test')\n \n \n \n \n \n# How to create engine and partition\n\n\n\n # VersionedCollapsingMergeTree \n \n df = pd.DataFrame([\n ['Y',0.4,1, 56],\n ['N',0.6,-1,34]\n ], columns=['status','probability','category','party'])\n \n \n df.clickhouse.drop(table='test333')\n \n df.clickhouse.VersionedCollapsingMergeTree(\n SIGN = 'category',\n VERSION = 'party',\n PARTITION = 'status', \n ORDER_BY = 'status',\n INDEX_GRANULARITY = 8192\n ) \n \n df.clickhouse.append(table='test333') \n \n# __________________________________________________________________\n\n # CollapsingMergeTree\n \n df = pd.DataFrame([\n ['Y',0.4,1],\n ['N',0.6,-1]\n ], columns=['status','probability','category'])\n \n \n df.clickhouse.drop(table='test333')\n \n df.clickhouse.CollapsingMergeTree(\n SIGN = 'category',\n PARTITION = 'status', \n ORDER_BY = 'status',\n INDEX_GRANULARITY = 8192\n ) \n \n df.clickhouse.append(table='test333')\n \n# __________________________________________________________________\n\n # CollapsingMergeTree\n\n df = pd.DataFrame([\n ['Y',0.4,1],\n ['N',0.6,-1]\n ], columns=['status','probability','category'])\n \n \n df.clickhouse.drop(table='test333')\n \n df.clickhouse.CollapsingMergeTree(\n SIGN = 'category',\n PARTITION = 'status', \n ORDER_BY = 'status',\n INDEX_GRANULARITY = 8192\n ) \n \n df.clickhouse.append(table='test333')\n \n# __________________________________________________________________\n \n # AggregatingMergeTree\n \n \n df = pd.DataFrame([\n ['Y',0.4,56],\n ['N',0.6,23]\n ], columns=['status','probability','category'])\n \n \n df.clickhouse.drop(table='test333')\n \n df.clickhouse.AggregatingMergeTree(\n PARTITION = 'status', \n ORDER_BY = 'status',\n INDEX_GRANULARITY = 8192\n ) \n \n df.clickhouse.append(table='test333')\n \n# __________________________________________________________________\n\n # Clean table\n df.clickhouse.truncate(table='test333')\n \n\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "phouse", "package_url": "https://pypi.org/project/phouse/", "platform": "", "project_url": "https://pypi.org/project/phouse/", "project_urls": null, "release_url": "https://pypi.org/project/phouse/1.7/", "requires_dist": null, "requires_python": "", "summary": "work with clickhouse", "version": "1.7" }, "last_serial": 5978140, "releases": { "1.4": [ { "comment_text": "", "digests": { "md5": "381a6fb18aec0487352049d245f0f248", "sha256": "7732c8fc1e9ad865b084bf35e22ea405b699f241c63432768db8d00a190c45c6" }, "downloads": -1, "filename": "phouse-1.4-py3.6.egg", "has_sig": false, "md5_digest": "381a6fb18aec0487352049d245f0f248", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 8309, "upload_time": "2019-10-15T15:39:55", "url": "https://files.pythonhosted.org/packages/7d/dc/9e4e665f6fd664c2af1cecb2454007db57eea9affef071c5dccede77f51c/phouse-1.4-py3.6.egg" } ], "1.6": [ { "comment_text": "", "digests": { "md5": "4b430eda41d631a3ae788ae7ba99f4b3", "sha256": "19ee87da3bd522a1179c6d14b6a1471a1f102fcd5677d343fde20809eff94ce4" }, "downloads": -1, "filename": "phouse-1.6-py3.6.egg", "has_sig": false, "md5_digest": "4b430eda41d631a3ae788ae7ba99f4b3", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 8333, "upload_time": "2019-10-15T15:45:23", "url": "https://files.pythonhosted.org/packages/ba/fd/5e360f9a2e4be9d40f4193f7247812c8243699ce3851b29b520e1550ee19/phouse-1.6-py3.6.egg" } ], "1.7": [ { "comment_text": "", "digests": { "md5": "677bf2b03229ac3e2834f3f91bd92906", "sha256": "47a25054167b30f343e4c9c4b73c30abffbaf2fce0b27a2d4df7024715945250" }, "downloads": -1, "filename": "phouse-1.7-py3.6.egg", "has_sig": false, "md5_digest": "677bf2b03229ac3e2834f3f91bd92906", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 8333, "upload_time": "2019-10-15T15:57:08", "url": "https://files.pythonhosted.org/packages/41/10/a0ddd4ddc1b46ac9f5e2f75b080e9d3846a828d1dce32803e7c10dba43f2/phouse-1.7-py3.6.egg" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "677bf2b03229ac3e2834f3f91bd92906", "sha256": "47a25054167b30f343e4c9c4b73c30abffbaf2fce0b27a2d4df7024715945250" }, "downloads": -1, "filename": "phouse-1.7-py3.6.egg", "has_sig": false, "md5_digest": "677bf2b03229ac3e2834f3f91bd92906", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 8333, "upload_time": "2019-10-15T15:57:08", "url": "https://files.pythonhosted.org/packages/41/10/a0ddd4ddc1b46ac9f5e2f75b080e9d3846a828d1dce32803e7c10dba43f2/phouse-1.7-py3.6.egg" } ] }