{"id":50351221,"url":"https://github.com/kxsystems/kdbx-db-service-q-client","last_synced_at":"2026-05-29T21:01:39.067Z","repository":{"id":360182924,"uuid":"1217866384","full_name":"KxSystems/kdbx-db-service-q-client","owner":"KxSystems","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-30T16:59:38.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T12:05:32.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"q","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:25.000Z","updated_at":"2026-04-30T17:27:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/KxSystems/kdbx-db-service-q-client","commit_stats":null,"previous_names":["kxsystems/kdbx-db-service-q-client"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/KxSystems/kdbx-db-service-q-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-q-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-q-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-q-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-q-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KxSystems","download_url":"https://codeload.github.com/KxSystems/kdbx-db-service-q-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Fkdbx-db-service-q-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:37.740Z","updated_at":"2026-05-29T21:01:39.061Z","avatar_url":"https://github.com/KxSystems.png","language":"q","funding_links":[],"categories":[],"sub_categories":[],"readme":"# q client for DB Service\n\nThe DB Service q client provides a thin wrapper over the DB Service APIs, making it easier to connect to a running service and perform client operations from q.\nUse this client to create a session, run queries, manage tables, and interact with DB Service from q.\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- kdb-x\n- A running DB Service instance\n\n### kdb-x installation\n\n`dbservice_client.q` is intended to be installed under the kdb-x module path.\nWhile it can be loaded from any directory, we recommend installing it to `$HOME/.kx/mod/kx`.\n\n```bash\ncp dbservice_client.q ~/.kx/mod/kx/\n```\n\nAdd the `QPATH` export to your `.bashrc` (or equivalent) to persist across sessions.\n\n### Load the client\nStart q and load the client:\n```q\n/ Load module\ndbs:use`kx.dbservice_client\n\n/ Default endpoint: http://localhost:8080\nsession:dbs.createSession[]\n\n/ Explicit endpoint\nsession1:dbs.createSession([endpoint:\"localhost:8080\"])\n\n/ Multiple DB Service instances from one q process\nsession2:dbs.createSession([endpoint:\"localhost:8081\"])\n```\n\n### Examples\n\nThis section shows common DB Service q 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```q\n// List tables (empty to begin with)\nsession.listTables[]\n\n// Define columns\nfxquoteCols:(`name`type!(\"trddate\";\"date\");`name`type!(\"ts\";\"timestamp\");`name`type`attrMem`attrDisk`attrOrd!(\"sym\";\"symbol\";\"grouped\";\"parted\";\"parted\");`name`type!(\"bid\";\"float\");`name`type!(\"ask\";\"float\"))\n\n// Create partitioned table ('fxquote')\nsession.createTable`table`type`prtnCol`sortColsDisk`sortColsOrd`columns!(\"fxquote\";\"partitioned\";\"ts\";enlist\"sym\";enlist\"sym\";fxquoteCols)\n\n// List tables ('fxquote' table returned)\nsession.listTables[]\n\n// Describe the 'fxquote' table\nsession.describeTable[\"fxquote\"]\n```\n\n#### Importing Data\nDB Service supports both `file-based` and `in-memory` ingest.\nAny 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```q\n// Import a CSV file into the existing 'fxquote' table\njob:session.importFiles([table:\"fxquote\";path:\"fxquote.csv.gz\"])\n\n// Check the status of the above import job\nsession.getImport[job`name]\n\n// Import a parquet file into the existing 'fxquote' table\nsession.importFiles([table:\"fxquote\";path:\"fxquote.parquet\"])\n\n// Import a CSV file and create the 'instruments' table automatically if it does not exist\njob:session.importFiles([table:\"instruments\";path:\"instruments.csv\";createTable:1b])\n```\n\n\n###### Import Kdb database\n```q\n// Import the 'fxquote' HDB table from the root kdb+ database directory 'fxquote-hdb'\nsession.importKDB([table:\"fxquote\";path:\"fxquote-hdb\"])\n```\n\n###### Import JSON\nImport rows directly from q without file staging.\n```q\n// Objects payload imported to 'instruments' table\ndata:([]instrumentid:77 78;sym:(\"USDBRL\";\"USDKRW\");category:(\"EM\";\"EM\");decimals:4 2;pipdecimals:4 2);\nsession.importData([table:\"instruments\";data])\n\n// Rows payload imported to the 'fxquote' table\ndata:((\"2026-01-21\";\"2026-01-21T10:00:00.000\";\"EURUSD\";901.2;901.3);(\"2026-01-21\";\"2026-01-21T10:00:00.000\";\"EURUSD\";901.2;901.3));\nsession.importData([table:\"fxquote\";data;columnNames:`trddate`ts`sym`bid`ask])\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```q\n// Structured query\nsession.querySimple([table:\"fxquote\";startTS:2026.03.02D;endTS:2026.03.03D;sortCols:enlist\"ts\";limit:5])\n\n// SQL query\nsession.querySQL([query:\"SELECT * FROM instruments WHERE category LIKE 'EM'\"])\n\n// qSQL query\nsession.queryQ([query:\"select o:first bid,h:max bid,l:min bid,c:last bid by trddate,sym from fxquote\"])\n```\n\n#### Deleting Tables\n\n```q\n// List tables (expected: 'fxquote' and 'instruments')\nsession.listTables[]\n```\n\n```q\n// Drop the 'fxquote' table\nsession.dropTable[\"fxquote\"]\n```\n\n```q\n// Drop the 'instruments' table\nsession.dropTable[\"instruments\"]\n```\n\n```q\n// List tables (expected: no tables)\nsession.listTables[]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkxsystems%2Fkdbx-db-service-q-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkxsystems%2Fkdbx-db-service-q-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkxsystems%2Fkdbx-db-service-q-client/lists"}