{"id":19725137,"url":"https://github.com/aresjef/mysqlengine","last_synced_at":"2026-03-05T11:05:23.464Z","repository":{"id":204086839,"uuid":"711085807","full_name":"AresJef/MysqlEngine","owner":"AresJef","description":"A Cython-Accelerated, Pythonic MySQL ORM \u0026 Query Builder","archived":false,"fork":false,"pushed_at":"2026-03-05T09:10:40.000Z","size":929,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-05T09:55:17.719Z","etag":null,"topics":["asynchronous","cython","mysql","orm","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AresJef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-28T07:05:48.000Z","updated_at":"2026-03-05T09:09:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"e4bf2970-162d-4adc-99f5-ec525fb87638","html_url":"https://github.com/AresJef/MysqlEngine","commit_stats":null,"previous_names":["aresjef/mysqlengine"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/AresJef/MysqlEngine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AresJef%2FMysqlEngine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AresJef%2FMysqlEngine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AresJef%2FMysqlEngine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AresJef%2FMysqlEngine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AresJef","download_url":"https://codeload.github.com/AresJef/MysqlEngine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AresJef%2FMysqlEngine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30121106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T10:44:24.758Z","status":"ssl_error","status_checked_at":"2026-03-05T10:44:15.079Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["asynchronous","cython","mysql","orm","python"],"created_at":"2024-11-11T23:28:23.698Z","updated_at":"2026-03-05T11:05:23.436Z","avatar_url":"https://github.com/AresJef.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## A Cython-Accelerated, Pythonic MySQL ORM \u0026 Query Builder\n\nCreated to be used in a project, this package is published to github for ease of management and installation across different modules.\n\n## Installation\n\nInstall from `PyPi`\n\n```bash\npip install mysqlengine\n```\n\nInstall from `github`\n\n```bash\npip install git+https://github.com/AresJef/MysqlEngine.git\n```\n\n## Requirements\n\n- Python 3.10 or higher.\n- MySQL 5.5 or higher.\n\n## Features\n\nMysqlEngine is a Python/Cython hybrid library that provides a high-performance, programmatic interface to MySQL. It provides:\n\n- An ORM-style schema definition via \u003c'Database'\u003e, \u003c'Table'\u003e, \u003c'Column'\u003e, etc.\n- A fluent query-builder (less hand-written SQL strings).\n- Built-in support for both sync and async workflows.\n- Custom \u003c'TimeTable'\u003e class to create and manage time-series partitions.\n- Critical parts are implemented in Cython, minimizing Python overhead and maximizing throughput.\n\nMysqlEngine is built on top of [SQLCyCli](https://github.com/AresJef/SQLCyCli). Because SQLCyCli already delivers solid and high-performance connectivity, MysqlEngine can concentrate on its higher-level features.\n\n- Delegates raw socket I/O, packet parsing, authentication, pooling, and cursor management to SQLCyCli.\n- All exeption is inherited from the `SQLCyCli.errors.MySQLError`.\n\n## Example (Normal Table)\n\n```python\nimport asyncio\nfrom mysqlengine import Database, Table, Pool\nfrom mysqlengine import Column, Index, Define, PrimaryKey\n\n\n# Difine Table\nclass User(Table):\n    id: Column = Column(Define.BIGINT(unsigned=True, auto_increment=True))\n    name: Column = Column(Define.VARCHAR(255))\n    pk: PrimaryKey = PrimaryKey(\"id\")\n    idx: Index = Index(\"name\")\n\n\nclass Product(Table):\n    id: Column = Column(Define.BIGINT(unsigned=True, auto_increment=True))\n    product_name: Column = Column(Define.VARCHAR(255))\n    product_price: Column = Column(Define.DECIMAL(12, 2))\n    pk: PrimaryKey = PrimaryKey(\"id\")\n    idx: Index = Index(\"product_name\")\n\n# Define Database\nclass MyDatabase(Database):\n    user: User = User()\n    product: Product = Product()\n\n# Instanciate Database\npool = Pool(host=\"localhost\", user=\"root\", password=\"Password_123456\")\ndb = MyDatabase(\"db\", pool)\n\n# Synchronize Demo\ndef sync_demo(db: MyDatabase) -\u003e None:\n    db.Initialize()  # Initialize 'db'\n    db.ShowDatabases()\n    db.user.ShowCreateTable()\n    db.user.ShowMetadata()\n    db.user.Insert().Columns(db.user.name).Values(1).Execute(\n        [\"John\", \"Sarah\"], many=True\n    )\n    db.Select(\"*\").From(db.user).Execute()  # ((1, 'John'), (2, 'Sarah'))\n    db.Drop()  # Drop 'db'\n\nsync_demo(db)\n\n# Asynchronize Demo\nasync def async_demo(db: MyDatabase) -\u003e None:\n    await db.aioInitialize()  # Initialize 'db'\n    await db.aioShowDatabases()\n    await db.user.aioShowCreateTable()\n    await db.user.aioShowMetadata()\n    await db.user.Insert().Columns(db.user.name).Values(1).aioExecute(\n        [\"John\", \"Sarah\"], many=True\n    )\n    await db.Select(\"*\").From(db.user).aioExecute()  # ((1, 'John'), (2, 'Sarah'))\n    await db.aioDrop()  # Drop 'db'\n\nasyncio.run(async_demo(db))\n```\n\n## Example (Temporary Table)\n\n```python\nimport asyncio\nfrom mysqlengine import Pool, Database, Table, TempTable\nfrom mysqlengine import Column, Index, Define, PrimaryKey\n\n\nclass MyTable(Table):\n    id: Column = Column(Define.BIGINT(unsigned=True, auto_increment=True))\n    name: Column = Column(Define.VARCHAR(255))\n    pk: PrimaryKey = PrimaryKey(\"id\")\n\n\nclass MyTempTable(TempTable):\n    id: Column = Column(Define.BIGINT(unsigned=True, auto_increment=True))\n    name: Column = Column(Define.VARCHAR(255))\n    pk: PrimaryKey = PrimaryKey(\"id\")\n\n\nclass MyDatabase(Database):\n    tb: MyTable = MyTable()\n\n\npool = Pool(host=\"localhost\", user=\"root\", password=\"Password_123456\")\ndb = MyDatabase(\"db\", pool)\ndb.Drop(True)\n\n# Synchronize Demo\ndef sync_demo(db: MyDatabase) -\u003e None:\n    db.Initialize()  # Initialize 'db'\n    db.tb.Insert().Columns(\"name\").Values(1).Execute([\"John\", \"Sarah\"], many=True)\n    with db.transaction() as conn:\n        with db.CreateTempTable(conn, \"temp_tb\", MyTempTable()) as tmp:\n            tmp.Insert().Columns(\"name\").Select(\"name\").From(db.tb).Execute()\n            tmp.Select(\"*\").Execute()  # ((1, 'John'), (2, 'Sarah'))\n    # temporary table is automatically dropped\n    db.Drop()  # Drop 'db'\n\nsync_demo(db)\n\n# Asynchronize Demo\nasync def async_demo(db: MyDatabase) -\u003e None:\n    await db.aioInitialize()  # Initialize 'db'\n    await db.tb.Insert().Columns(\"name\").Values(1).aioExecute(\n        [\"John\", \"Sarah\"], many=True\n    )\n    async with db.transaction() as conn:\n        async with db.CreateTempTable(conn, \"temp_tb\", MyTempTable()) as tmp:\n            await tmp.Insert().Columns(\"name\").Select(\"name\").From(db.tb).aioExecute()\n            await tmp.Select(\"*\").aioExecute()  # ((1, 'John'), (2, 'Sarah'))\n    # temporary table is automatically dropped\n    await db.aioDrop()  # Drop 'db'\n\nasyncio.run(async_demo(db))\n```\n\n## Example (Time Table)\n\n```python\nimport asyncio\nfrom mysqlengine import Pool, Database, TimeTable\nfrom mysqlengine import Column, Index, Define, PrimaryKey\n\n\nclass MyTimeTable(TimeTable):\n    id: Column = Column(Define.BIGINT(unsigned=True, auto_increment=True))\n    name: Column = Column(Define.VARCHAR(255))\n    dt: Column = Column(Define.DATETIME())\n    pk: PrimaryKey = PrimaryKey(\"id\", \"dt\")\n\n\nclass MyDatabase(Database):\n    tb: MyTimeTable = MyTimeTable(\"dt\", \"YEAR\", \"2024-01-01\", \"2025-01-01\")\n\n\npool = Pool(host=\"localhost\", user=\"root\", password=\"Password_123456\")\ndb = MyDatabase(\"db\", pool)\ndb.Drop(True)\n\n# Synchronize Demo\ndef sync_demo(db: MyDatabase) -\u003e None:\n    db.Initialize()  # Initialize 'db'\n    db.tb.Insert().Columns(\"name\", \"dt\").Values(2).Execute(\n        [(\"John\", \"2024-02-01\"), (\"Sarah\", \"2025-02-01\")], many=True\n    )\n    db.tb.ShowPartitionRows()  # {'past': 0, 'y2024': 1, 'y2025': 1, 'future': 0}\n    db.tb.ExtendToTime(end_with=\"2026-02-01\")\n    db.tb.ShowPartitionRows()  # {'past': 0, 'y2024': 1, 'y2025': 1, 'y2026': 0, 'future': 0}\n    db.tb.DropToTime(start_from=\"2025-01-01\")\n    db.tb.ShowPartitionRows()  # {'past': 0, 'y2025': 1, 'y2026': 0, 'future': 0}\n    db.Drop()  # Drop 'db'\n\nsync_demo(db)\n\n# Asynchronize Demo\nasync def async_demo(db: MyDatabase) -\u003e None:\n    await db.aioInitialize()  # Initialize 'db'\n    await db.tb.Insert().Columns(\"name\", \"dt\").Values(2).aioExecute(\n        [(\"John\", \"2024-02-01\"), (\"Sarah\", \"2025-02-01\")], many=True\n    )\n    await db.tb.aioShowPartitionRows()  # {'past': 0, 'y2024': 1, 'y2025': 1, 'future': 0}\n    await db.tb.aioExtendToTime(end_with=\"2026-02-01\")\n    await db.tb.aioShowPartitionRows()  # {'past': 0, 'y2024': 1, 'y2025': 1, 'y2026': 0, 'future': 0}\n    await db.tb.aioDropToTime(start_from=\"2025-01-01\")\n    await db.tb.aioShowPartitionRows()  # {'past': 0, 'y2025': 1, 'y2026': 0, 'future': 0}\n    await db.aioDrop()  # Drop 'db'\n\nasyncio.run(async_demo(db))\n```\n\n### Acknowledgements\n\nMysqlEngine is based on several open-source repositories.\n\n- [cytimes](https://github.com/AresJef/cyTimes)\n- [numpy](https://github.com/numpy/numpy)\n- [pandas](https://github.com/pandas-dev/pandas)\n- [SQLCyCli](https://github.com/AresJef/SQLCyCli)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faresjef%2Fmysqlengine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faresjef%2Fmysqlengine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faresjef%2Fmysqlengine/lists"}