{"id":13342854,"url":"https://github.com/grafana/xk6-sql","last_synced_at":"2026-01-11T22:46:56.268Z","repository":{"id":37921377,"uuid":"306383338","full_name":"grafana/xk6-sql","owner":"grafana","description":"Use SQL databases from k6 tests.","archived":false,"fork":false,"pushed_at":"2025-12-12T17:09:10.000Z","size":2714,"stargazers_count":173,"open_issues_count":22,"forks_count":63,"subscribers_count":59,"default_branch":"main","last_synced_at":"2025-12-14T08:01:41.400Z","etag":null,"topics":["k6","sql","xk6"],"latest_commit_sha":null,"homepage":"http://sql.x.k6.io/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mostafa/k6-plugin-sql","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","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":"2020-10-22T15:37:40.000Z","updated_at":"2025-12-09T08:32:02.000Z","dependencies_parsed_at":"2023-11-20T18:26:16.515Z","dependency_job_id":"ad15da2c-d372-4e29-bc11-51d8fee32b78","html_url":"https://github.com/grafana/xk6-sql","commit_stats":{"total_commits":78,"total_committers":21,"mean_commits":"3.7142857142857144","dds":0.6923076923076923,"last_synced_commit":"cb63ffc55c5118a83b1a289977371fc2ae0f9332"},"previous_names":["imiric/k6-plugin-sql","imiric/xk6-sql"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/grafana/xk6-sql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/xk6-sql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-sql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28326144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T22:11:01.104Z","status":"ssl_error","status_checked_at":"2026-01-11T22:10:58.990Z","response_time":60,"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":["k6","sql","xk6"],"created_at":"2024-07-29T19:30:06.209Z","updated_at":"2026-01-11T22:46:56.259Z","avatar_url":"https://github.com/grafana.png","language":"Go","readme":"[![API Reference](https://img.shields.io/badge/API-reference-blue?logo=readme\u0026logoColor=lightgray)](https://sql.x.k6.io)\n[![GitHub Release](https://img.shields.io/github/v/release/grafana/xk6-sql)](https://github.com/grafana/xk6-sql/releases/latest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/grafana/xk6-sql)](https://goreportcard.com/report/github.com/grafana/xk6-sql)\n[![GitHub Actions](https://github.com/grafana/xk6-sql/actions/workflows/validate.yml/badge.svg)](https://github.com/grafana/xk6-sql/actions/workflows/validate.yml)\n\n# xk6-sql\n\n**Use SQL databases from k6 tests.**\n\nxk6-sql is a [Grafana k6 extension](https://grafana.com/docs/k6/latest/extensions/) that enables the use of SQL databases in [k6](https://grafana.com/docs/k6/latest/) tests.\n\nCheck out the API documentation [here](https://sql.x.k6.io). The TypeScript declaration file can be downloaded from [here](https://sql.x.k6.io/index.d.ts).\n\nTo use the TypeScript declaration file in your IDE (e.g. Visual Studio Code), you need to create a `jsconfig.json` (or `tsconfig.json`) file with the following content:\n\n```json file=examples/jsconfig.json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES6\",\n    \"module\": \"ES6\",\n    \"paths\": {\n      \"k6/x/sql\": [\"./typings/xk6-sql/index.d.ts\"]\n    }\n  }\n}\n```\n\nYou will need to update the TypeScript declaration file location in the example above to where you downloaded it.\n\n## Usage\n\nTo use the xk6-sql API, the `k6/x/sql` module and the driver module corresponding to the database type should be imported. In the example below, `k6/x/sql/driver/ramsql` is the RamSQL database driver module.\n\nThe driver module exports a driver ID. This driver identifier should be used to identify the database driver to be used in the API functions.\n\n**example**\n\n```javascript file=examples/example.js\nimport sql from \"k6/x/sql\";\n\n// the actual database driver should be used instead of ramsql\nimport driver from \"k6/x/sql/driver/ramsql\";\n\nconst db = sql.open(driver, \"roster_db\");\n\nexport function setup() {\n  db.exec(`\n    CREATE TABLE IF NOT EXISTS roster\n      (\n        id INTEGER PRIMARY KEY AUTOINCREMENT,\n        given_name VARCHAR NOT NULL,\n        family_name VARCHAR NOT NULL\n      );\n  `);\n}\n\nexport function teardown() {\n  db.close();\n}\n\nexport default function () {\n  let result = db.exec(`\n    INSERT INTO roster\n      (given_name, family_name)\n    VALUES\n      ('Peter', 'Pan'),\n      ('Wendy', 'Darling'),\n      ('Tinker', 'Bell'),\n      ('James', 'Hook');\n  `);\n  console.log(`${result.rowsAffected()} rows inserted`);\n\n  let rows = db.query(\"SELECT * FROM roster WHERE given_name = $1;\", \"Peter\");\n  for (const row of rows) {\n    console.log(`${row.family_name}, ${row.given_name}`);\n  }\n}\n```\n\n## Build\n\nThe [xk6](https://github.com/grafana/xk6) build tool can be used to build a k6 that will include **xk6-sql** extension and database drivers.\n\n\u003e [!IMPORTANT]\n\u003e In the command line bellow, **xk6-sql-driver-ramsql** is just an example, it should be replaced with the database driver extension you want to use.\n\u003e For example use `--with github.com/grafana/xk6-sql-driver-mysql` to access MySQL databases.\n\n```bash\nxk6 build --with github.com/grafana/xk6-sql@latest --with github.com/grafana/xk6-sql-driver-ramsql\n```\n\nFor more build options and how to use xk6, check out the [xk6 documentation](https://github.com/grafana/xk6).\n\nSupported RDBMSs includes: `mysql`, `postgres`, `sqlite3`, `sqlserver`, `azuresql`, `clickhouse`.\n\nCheck the [xk6-sql-driver GitHub topic](https://github.com/topics/xk6-sql-driver) to discover database driver extensions.\n\n## Drivers\n\nTo use the xk6-sql extension, one or more database driver extensions should also be embedded. Database driver extension names typically start with the prefix `xk6-sql-driver-` followed by the name of the database, for example `xk6-sql-driver-mysql` is the name of the MySQL database driver extension.\n\nFor easier discovery, the `xk6-sql-driver` topic is included in the database driver extensions repository. The [xk6-sql-driver GitHub topic search](https://github.com/topics/xk6-sql-driver) therefore lists the available driver extensions.\n\n### Create driver\n\nCheck the [grafana/xk6-sql-driver-ramsql](https://github.com/grafana/xk6-sql-driver-ramsql) template repository to create a new driver extension. This is a working driver extension with instructions in its README for customization.\n\n[Postgres driver extension](https://github.com/grafana/xk6-sql-driver-postgres) and [MySQL driver extension](https://github.com/grafana/xk6-sql-driver-mysql) are also good examples.\n\n## Feedback\n\nIf you find the **xk6-sql** extension useful, please star the repo. The number of stars will affect the time allocated for maintenance.\n\n[![Stargazers over time](https://starchart.cc/grafana/xk6-sql.svg?variant=adaptive)](https://starchart.cc/grafana/xk6-sql)\n\n## Contribute\n\nIf you want to contribute or help with the development of **xk6-sql**, start by reading [CONTRIBUTING.md](CONTRIBUTING.md). \n","funding_links":[],"categories":["Extensions"],"sub_categories":["Official"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fxk6-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-sql/lists"}