{"id":31176159,"url":"https://github.com/evandrolg/clickhouse-lua","last_synced_at":"2025-09-19T13:58:58.219Z","repository":{"id":304328941,"uuid":"1010554677","full_name":"EvandroLG/clickhouse-lua","owner":"EvandroLG","description":"A simple, lightweight HTTP-based ClickHouse client for Lua 🗄️","archived":false,"fork":false,"pushed_at":"2025-07-12T10:49:52.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-12T12:32:31.346Z","etag":null,"topics":["clickhouse","database","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EvandroLG.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}},"created_at":"2025-06-29T10:22:19.000Z","updated_at":"2025-07-12T10:49:55.000Z","dependencies_parsed_at":"2025-07-13T04:16:08.650Z","dependency_job_id":null,"html_url":"https://github.com/EvandroLG/clickhouse-lua","commit_stats":null,"previous_names":["evandrolg/clickhouse-lua"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/EvandroLG/clickhouse-lua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvandroLG%2Fclickhouse-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvandroLG%2Fclickhouse-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvandroLG%2Fclickhouse-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvandroLG%2Fclickhouse-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvandroLG","download_url":"https://codeload.github.com/EvandroLG/clickhouse-lua/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvandroLG%2Fclickhouse-lua/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275951017,"owners_count":25558392,"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","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["clickhouse","database","lua"],"created_at":"2025-09-19T13:58:53.012Z","updated_at":"2025-09-19T13:58:58.198Z","avatar_url":"https://github.com/EvandroLG.png","language":"Lua","readme":"# clickhouse-lua \u0026middot; [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![Lua Version](https://img.shields.io/badge/Lua-5.1%2B-blue.svg)](https://www.lua.org/)\n\nA simple, lightweight HTTP-based ClickHouse client for Lua.\n\n## Features\n\n- **Simple API**: Easy-to-use interface for ClickHouse operations\n- **HTTP-based**: Uses ClickHouse's HTTP interface for maximum compatibility\n- **Multiple Formats**: Support for JSONEachRow, JSON, TabSeparated, and more\n- **Auto-detection**: Automatically detects HTTP method based on SQL command\n- **Lightweight**: Minimal dependencies, pure Lua implementation\n\n## Installation\n\n```bash\nluarocks install clickhouse\n```\n\n## Quick Start\n\n```lua\nlocal clickhouse = require(\"clickhouse\")\nlocal client = clickhouse.ClickHouseClient.new({\n    host = \"localhost\",\n    port = 8123,\n    username = \"default\",\n    password = \"\",\n    database = \"default\"\n})\n\n-- Test connection\nlocal success, err = client:ping()\nif success then\n    print(\"Connected to ClickHouse!\")\nelse\n    print(\"Connection failed:\", err)\nend\n\n-- Execute a simple query\nlocal result, err = client:query(\"SELECT version()\")\nif result then\n    print(\"ClickHouse version:\", result[1].version)\nelse\n    print(\"Query failed:\", err)\nend\n```\n\n## API Reference\n\n### Constructor\n\n#### `ClickHouseClient.new(config)`\n\nCreates a new ClickHouse client instance.\n\n**Parameters:**\n\n- `config` (table): Configuration options\n  - `host` (string): ClickHouse server host (default: \"localhost\")\n  - `port` (number): ClickHouse server port (default: 8123)\n  - `username` (string): Username for authentication (default: \"default\")\n  - `password` (string): Password for authentication (default: \"\")\n  - `database` (string): Default database to use (default: \"default\")\n  - `timeout` (number): Request timeout in seconds (default: 30)\n  - `format` (string): Default format for data exchange (default: \"JSONEachRow\")\n\n**Returns:** `ClickHouseClient` instance\n\n### Methods\n\n#### `client:ping()`\n\nTests the connection to ClickHouse server.\n\n**Returns:**\n\n- `success` (boolean): True if connection is successful\n- `error` (string|nil): Error message if connection failed\n\n#### `client:query(sql, params)`\n\nExecutes a SQL query against ClickHouse.\n\n**Parameters:**\n\n- `sql` (string): SQL query to execute\n- `params` (table|nil): Optional parameters\n  - `format` (string): Response format (overrides default)\n  - `method` (string): HTTP method (\"GET\" or \"POST\", auto-detected if not specified)\n  - Additional key-value pairs are passed as URL parameters\n\n**Returns:**\n\n- `result` (table|string|nil): Query results (parsed or raw depending on format)\n- `error` (string|nil): Error message if query failed\n\n#### `client:insert(table_name, data, params)`\n\nInserts data into a ClickHouse table.\n\n**Parameters:**\n\n- `table_name` (string): Name of the target table\n- `data` (table): Array of objects to insert\n- `params` (table|nil): Optional parameters\n  - `format` (string): Data format (\"JSONEachRow\" or \"JSON\", default: \"JSONEachRow\")\n\n**Returns:**\n\n- `success` (boolean|nil): True if insertion succeeded\n- `error` (string|nil): Error message if insertion failed\n\n## License\n\n[MIT](https://github.com/EvandroLG/ts-audio/tree/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevandrolg%2Fclickhouse-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevandrolg%2Fclickhouse-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevandrolg%2Fclickhouse-lua/lists"}