{"id":50351140,"url":"https://github.com/kxsystems/kdbx-db-service-python-client","last_synced_at":"2026-05-29T21:01:34.627Z","repository":{"id":360182925,"uuid":"1217866205","full_name":"KxSystems/kdbx-db-service-python-client","owner":"KxSystems","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-30T16:58:40.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T12:05:32.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KxSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2026-04-22T09:46:13.000Z","updated_at":"2026-04-30T17:27:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/KxSystems/kdbx-db-service-python-client","commit_stats":null,"previous_names":["kxsystems/kdbx-db-service-python-client"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/KxSystems/kdbx-db-service-python-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-python-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-python-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-python-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-python-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KxSystems","download_url":"https://codeload.github.com/KxSystems/kdbx-db-service-python-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-python-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33670211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"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":[],"created_at":"2026-05-29T21:01:33.998Z","updated_at":"2026-05-29T21:01:34.618Z","avatar_url":"https://github.com/KxSystems.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python client for DB Service\n\nThe DB Service Python client provides a thin wrapper over the DB Service APIs, making it easier to connect to a running service and perform client operations from Python.\n\nUse this client to create a session, run queries, manage tables, and interact with DB Service from Python.\n\nExamples of using the client are included below. For a comprehensive list of parameters and their meanings, refer to the [KDB-X DB Service API spec](https://code.kx.com/kdb-x/services/db-service/api/dbservice.html).\n\n### Requirements\n\n- Python 3.x\n- A running DB Service instance\n\n\n### Install\n\n```bash\n# Install the client\npip install --pre --index https://portal.dl.kx.com/assets/pypi kdbx-db-service-client\n```\n\nFor KDB-X Python installation and environment setup, see the [KDB-X Python install guide](https://code.kx.com/kdb-x/get_started/kdb-x-python-install.html).\n\n### Connect\n\nCreate a session to connect to DB Service:\n\n```python\nimport dbservice_client as dbs\nimport pandas as pd  # Query examples return dataframes\nfrom datetime import datetime as dt, timezone, timedelta\n\n# Default endpoint: localhost:8080\nsession = dbs.Session()\n\n# Optional explicit endpoint\nrest_session = dbs.Session(endpoint=\"localhost:8080\")\n```\n\n### Examples\n\nThis section shows common DB Service Python client workflows, including table management, data import, querying, and deleting tables.\n\n#### Managing Tables\nUse these calls to define and inspect table schemas in DB Service. \n\n```python\n# List tables (empty to begin with)\nsession.list_tables()\n\n# Create partitioned table ('fxquote')\nsession.create_table(\n    table=\"fxquote\",\n    type=\"partitioned\",\n    prtnCol=\"ts\",\n    sortColsDisk=[\"sym\"],\n    sortColsOrd=[\"sym\"],\n    columns=[\n        {\"name\": \"trddate\", \"type\": \"date\"},\n        {\"name\": \"ts\", \"type\": \"timestamp\"},\n        {\"name\": \"sym\", \"type\": \"symbol\", \"attrMem\": \"grouped\", \"attrDisk\": \"parted\", \"attrOrd\": \"parted\"},\n        {\"name\": \"bid\", \"type\": \"float\"},\n        {\"name\": \"ask\", \"type\": \"float\"},\n    ]\n)\n\n# List tables ('fxquote' table returned)\nsession.list_tables()\n\n# Describe the 'fxquote' table\nsession.describe_table(table=\"fxquote\")\n```\n\n#### Importing Data\nDB Service supports both `file-based` and `in-memory` ingest. Any file you want to import must first be copied into the DB Service `imports` staging directory, for example: `~/.kx/db-service/data/imports/`\n\n###### Import CSV\n```python\n# Import a CSV file into the existing 'fxquote' table\njob = session.import_files(table=\"fxquote\", path=\"fxquote.csv.gz\")\n\n# Check the status of the above import job\nsession.get_import(job_id=job[\"name\"])\n\n# Import a parquet file into the existing 'fxquote' table\nsession.import_files(table='fxquote', path='fxquote.parquet')\n\n# Import a CSV file and create the 'instruments' table automatically if it does not exist\nsession.import_files(table=\"instruments\", path=\"instruments.csv\", createTable=True)\n```\n\n###### Import Kdb database\n```python\n# Import the 'fxquote' HDB table from the root kdb+ database directory 'fxquote-hdb'\nsession.import_database(table=\"fxquote\", path=\"fxquote-hdb\")\n```\n\n###### Import JSON\n\nUsers can import data directly from Python without file staging\n\n```python\n# Objects payload imported to 'instruments' table\njob = session.import_data(\n    table=\"instruments\",\n    data=[\n        {\"instrumentid\": 77, \"sym\": \"USDBRL\", \"category\": \"EM\", \"decimals\": 4, \"pipdecimals\": 4},\n        {\"instrumentid\": 78, \"sym\": \"USDKRW\", \"category\": \"EM\", \"decimals\": 2, \"pipdecimals\": 2},\n    ],\n    insert_as=\"objects\",\n)\n\n# Rows payload imported to the 'fxquote' table\nsession.import_data(\n    table=\"fxquote\",\n    data=[\n        [\"2026-01-21\", \"2026-01-21T10:00:00.000\", \"EURUSD\", 901.2, 901.3],\n        [\"2026-01-21\", \"2026-01-21T10:00:00.000\", \"EURUSD\", 901.2, 901.3],\n    ],\n    columnNames=[\"trddate\", \"ts\", \"sym\", \"bid\", \"ask\"],\n    insert_as=\"rows\",\n)\n# Note: for rows payload, columnNames are required.\n```\n\n#### Querying Tables\nRun structured, SQL, or q queries against DB Service.\n\n```python\n# Structured query\nsession.query_simple(\n    table=\"fxquote\",\n    startTS=\"2026.03.02D00:00:00.000\",\n    endTS=\"2026.03.03D00:00:00.000\",\n    sortCols=[\"ts\"],\n    limit=5,\n    return_as=\"json\",\n)\n\n# SQL query\nsession.query_sql(\n    query=\"SELECT * FROM instruments WHERE category LIKE 'EM'\",\n    return_as=\"pandas\",\n)\n\n# QSQL query\nsession.query_q(\n    query='select o:first bid,h:max bid,l:min bid,c:last bid by trddate,sym from fxquote',\n    return_as=\"pandas\",\n)\n```\n\n\u003e **Return format:** `return_as` may be `json`, `pandas`, or `pykx`. If omitted, it defaults to `json`.\n#### Deleting Tables\n```python\n# List tables (expected: 'fxquote' and 'instruments')\nsession.list_tables()\n\n# Drop the 'fxquote' table\nsession.drop_table(table=\"fxquote\")\n\n# Drop the 'instruments' table\nsession.drop_table(table=\"instruments\")\n\n# List tables (expected: no tables)\nsession.list_tables()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkxsystems%2Fkdbx-db-service-python-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkxsystems%2Fkdbx-db-service-python-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkxsystems%2Fkdbx-db-service-python-client/lists"}