==============================
module mining data in OLAP
==============================
* Raw Query:
```python
from mobio.libs.olap.mining_warehouse.base_engine.base_session import BaseSession
from sqlalchemy import text
class JourneyReportHandle:
def __init__(self, olap_uri, sniff=False):
self.session = BaseSession(olap_uri=olap_uri, sniff=sniff)
def get_journey_by_id(self, record_id):
stmt = """
select `name` from report where id=:record_id
"""
with self.session.SessionLocal() as session:
result = session.execute(
text(stmt),
{"id": record_id},
).first()
session.close()
return result
if __name__ == "__main__":
with JourneyReportHandle(
olap_uri="mobio://user:pass@host:host/default_catalog.journey_builder"
).session.SessionLocal() as ss:
result1 = list(
ss.execute(
text(
"""
select id from report limit 10
"""
),
).all()
)
ss.close()
print("result1 {}".format(result1))
```
* ORM:
```python
from sqlalchemy.orm import declarative_base
from mobio.libs.olap.mining_warehouse.base_engine.base_session import BaseSession
from sqlalchemy import Column, String
Base = declarative_base()
class BaseModel(Base):
__abstract__ = True
def __init__(self, olap_uri, sniff=False):
super(BaseModel, self).__init__()
self.session = BaseSession(olap_uri=olap_uri, sniff=sniff)
pass
class JourneyReport(BaseModel):
__tablename__ = "report"
id = Column(String(36), primary_key=True)
journey_id = Column(String(36))
instance_id = Column(String(36))
def __repr__(self):
return f"JourneyReport(id={self.id!r}, journey_id={self.journey_id!r}, instance_id={self.instance_id!r})"
if __name__ == "__main__":
with JourneyReport(
olap_uri="mobio://user:pass@host:host/default_catalog.journey_builder"
).session.SessionLocal() as ss3:
result3 = ss3.query(JourneyReport).limit(10).all()
print("result3 {}".format(result3))
```
Release notes:
* 0.1.14 (2024-06-04):
* dùng pymysql thay cho MySQL-Client
* 0.1.13 (2024-01-06):
* Fix issue create connection when cluster only has leader
* support sniff frontends
* 0.1.12 (2024-01-06):
* support HA
* 0.1.11 (2023-12-07):
* port libs
* 0.1.4 (2023-11-28):
* fix validate column name, support dynamic field with prefix
* 0.1.3 (2023-11-27):
* remove m-utilities, chỉ dependence m-logging để support python3.8
* 0.1.2 (2023-11-27):
* alter table
* 0.1.1 (2023-11-24):
* support lấy profile by id, hỗ trợ việc masking data
Raw data
{
"_id": null,
"home_page": "https://github.com/mobiovn",
"name": "m-olap-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "mobio, olap, m-olap, data-warehouse",
"author": "MOBIO",
"author_email": "contact@mobio.vn",
"download_url": "https://files.pythonhosted.org/packages/e4/4e/884e395c0c475707641531f4df98f3591ca7d6b63b4cff09c8b53892f248/m_olap_sdk-0.1.14.tar.gz",
"platform": null,
"description": "\n==============================\n\n module mining data in OLAP\n\n==============================\n\n* Raw Query: \n```python\nfrom mobio.libs.olap.mining_warehouse.base_engine.base_session import BaseSession\nfrom sqlalchemy import text\n\n\nclass JourneyReportHandle:\n def __init__(self, olap_uri, sniff=False):\n self.session = BaseSession(olap_uri=olap_uri, sniff=sniff)\n\n def get_journey_by_id(self, record_id):\n stmt = \"\"\"\n select `name` from report where id=:record_id\n \"\"\"\n with self.session.SessionLocal() as session:\n result = session.execute(\n text(stmt),\n {\"id\": record_id},\n ).first()\n session.close()\n\n return result\n\nif __name__ == \"__main__\":\n with JourneyReportHandle(\n olap_uri=\"mobio://user:pass@host:host/default_catalog.journey_builder\"\n ).session.SessionLocal() as ss:\n result1 = list(\n ss.execute(\n text(\n \"\"\"\n select id from report limit 10\n \"\"\"\n ),\n ).all()\n )\n ss.close()\n print(\"result1 {}\".format(result1))\n```\n\n* ORM:\n```python\nfrom sqlalchemy.orm import declarative_base\nfrom mobio.libs.olap.mining_warehouse.base_engine.base_session import BaseSession\nfrom sqlalchemy import Column, String\n\nBase = declarative_base()\n\n\nclass BaseModel(Base):\n __abstract__ = True\n\n def __init__(self, olap_uri, sniff=False):\n super(BaseModel, self).__init__()\n self.session = BaseSession(olap_uri=olap_uri, sniff=sniff)\n pass\n\n\nclass JourneyReport(BaseModel):\n __tablename__ = \"report\"\n\n id = Column(String(36), primary_key=True)\n journey_id = Column(String(36))\n instance_id = Column(String(36))\n\n def __repr__(self):\n return f\"JourneyReport(id={self.id!r}, journey_id={self.journey_id!r}, instance_id={self.instance_id!r})\"\n\nif __name__ == \"__main__\":\n with JourneyReport(\n olap_uri=\"mobio://user:pass@host:host/default_catalog.journey_builder\"\n ).session.SessionLocal() as ss3:\n result3 = ss3.query(JourneyReport).limit(10).all()\n print(\"result3 {}\".format(result3))\n```\n\n\nRelease notes:\n* 0.1.14 (2024-06-04):\n * d\u00f9ng pymysql thay cho MySQL-Client\n* 0.1.13 (2024-01-06):\n * Fix issue create connection when cluster only has leader\n * support sniff frontends\n* 0.1.12 (2024-01-06):\n * support HA\n* 0.1.11 (2023-12-07):\n * port libs\n* 0.1.4 (2023-11-28):\n * fix validate column name, support dynamic field with prefix\n* 0.1.3 (2023-11-27):\n * remove m-utilities, ch\u1ec9 dependence m-logging \u0111\u1ec3 support python3.8\n* 0.1.2 (2023-11-27):\n * alter table\n* 0.1.1 (2023-11-24):\n * support l\u1ea5y profile by id, h\u1ed7 tr\u1ee3 vi\u1ec7c masking data\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Mobio OLAP SDK",
"version": "0.1.14",
"project_urls": {
"Homepage": "https://github.com/mobiovn",
"Source": "https://github.com/mobiovn"
},
"split_keywords": [
"mobio",
" olap",
" m-olap",
" data-warehouse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e44e884e395c0c475707641531f4df98f3591ca7d6b63b4cff09c8b53892f248",
"md5": "8d924a37b3f5c2b22d980fcfe3f21cee",
"sha256": "d39426227a85332e6494e2b2b3c7931e7e7b55533c0ca849acace0e33236498f"
},
"downloads": -1,
"filename": "m_olap_sdk-0.1.14.tar.gz",
"has_sig": false,
"md5_digest": "8d924a37b3f5c2b22d980fcfe3f21cee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 22594,
"upload_time": "2024-06-04T09:31:55",
"upload_time_iso_8601": "2024-06-04T09:31:55.938168Z",
"url": "https://files.pythonhosted.org/packages/e4/4e/884e395c0c475707641531f4df98f3591ca7d6b63b4cff09c8b53892f248/m_olap_sdk-0.1.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-04 09:31:55",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "m-olap-sdk"
}