{"id":13342824,"url":"https://github.com/msaf1980/xk6-sqlx","last_synced_at":"2025-03-16T18:13:23.776Z","repository":{"id":108916500,"uuid":"562594604","full_name":"msaf1980/xk6-sqlx","owner":"msaf1980","description":"k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3) ","archived":false,"fork":false,"pushed_at":"2022-11-06T20:58:55.000Z","size":2492,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T04:42:08.443Z","etag":null,"topics":["k6","k6-extension","sql","xk6"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msaf1980.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2022-11-06T20:20:57.000Z","updated_at":"2022-11-06T20:22:06.000Z","dependencies_parsed_at":"2023-04-21T06:29:09.501Z","dependency_job_id":null,"html_url":"https://github.com/msaf1980/xk6-sqlx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf1980%2Fxk6-sqlx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf1980%2Fxk6-sqlx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf1980%2Fxk6-sqlx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf1980%2Fxk6-sqlx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msaf1980","download_url":"https://codeload.github.com/msaf1980/xk6-sqlx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910814,"owners_count":20367545,"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","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","k6-extension","sql","xk6"],"created_at":"2024-07-29T19:30:05.866Z","updated_at":"2025-03-16T18:13:23.737Z","avatar_url":"https://github.com/msaf1980.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xk6-sql\n\nThis is a [k6](https://github.com/grafana/k6) extension using the\n[xk6](https://github.com/grafana/xk6) system.\n\nSupported RDBMSs: `mysql`, `postgres`, `sqlite3`, `sqlserver`. See the [tests](tests)\ndirectory for examples. Other RDBMSs are not supported, see\n[details below](#support-for-other-rdbmss).\n\nBased on [xk6-sql] (https://github.com/msaf1980/xk6-sql) exrension, but also support naming parameters.\n\n## Build\n\nTo build a `k6` binary with this plugin, first ensure you have the prerequisites:\n\n- [Go toolchain](https://go101.org/article/go-toolchain.html)\n- If you're using SQLite, a build toolchain for your system that includes `gcc` or\n  another C compiler. On Debian and derivatives install the `build-essential`\n  package. On Windows you can use [tdm-gcc](https://jmeubank.github.io/tdm-gcc/).\n  Make sure that `gcc` is in your `PATH`.\n- Git\n\nThen:\n\n1. Install `xk6`:\n  ```shell\n  go install go.k6.io/xk6/cmd/xk6@latest\n  ```\n\n2. Build the binary:\n  ```shell\n  xk6 build --with github.com/msaf1980/xk6-sqlx\n  ```\n\n  If you're using SQLite, ensure you have a C compiler installed (see the\n  prerequisites note) and set `CGO_ENABLED=1` in the environment:\n  ```shell\n  CGO_ENABLED=1 xk6 build --with github.com/msaf1980/xk6-sqlx\n  ```\n\n  On Windows this is done slightly differently:\n  ```shell\n  set CGO_ENABLED=1\n  xk6 build --with github.com/msaf1980/xk6-sqlx\n  ```\n\n## Development\nTo make development a little smoother, use the `Makefile` in the root folder. The default target will format your code, run tests, and create a `k6` binary with your local code rather than from GitHub.\n\n```bash\nmake\n```\nOnce built, you can run your newly extended `k6` using:\n```shell\n ./k6 run tests/sqlite3_test.js\n ```\n\n## Example\n\n```javascript\n// script.js\nimport sql from 'k6/x/sql';\n\nconst db = sql.open(\"sqlite3\", \"./test.db\");\n\nexport function setup() {\n  db.exec(`CREATE TABLE IF NOT EXISTS keyvalues (\n           id integer PRIMARY KEY AUTOINCREMENT,\n           key varchar NOT NULL,\n           value varchar);`);\n}\n\nexport function teardown() {\n  db.close();\n}\n\nexport default function () {\n  db.exec(\"INSERT INTO keyvalues (key, value) VALUES('plugin-name', 'k6-plugin-sql');\");\n\n  let results = sql.query(db, \"SELECT * FROM keyvalues;\");\n  for (const row of results) {\n    console.log(`key: ${row.key}, value: ${row.value}`);\n  }\n}\n```\n\nResult output:\n\n```shell\n$ ./k6 run script.js\n\n          /\\      |‾‾| /‾‾/   /‾‾/\n     /\\  /  \\     |  |/  /   /  /\n    /  \\/    \\    |     (   /   ‾‾\\\n   /          \\   |  |\\  \\ |  (‾)  |\n  / __________ \\  |__| \\__\\ \\_____/ .io\n\n  execution: local\n     script: /tmp/script.js\n     output: -\n\n  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):\n           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)\n\nINFO[0000] key: plugin-name, value: k6-plugin-sql        source=console\n\nrunning (00m00.1s), 0/1 VUs, 1 complete and 0 interrupted iterations\ndefault ✓ [======================================] 1 VUs  00m00.0s/10m0s  1/1 iters, 1 per VU\n\n    █ setup\n\n    █ teardown\n\n    data_received........: 0 B 0 B/s\n    data_sent............: 0 B 0 B/s\n    iteration_duration...: avg=9.22ms min=19.39µs med=8.86ms max=18.8ms p(90)=16.81ms p(95)=17.8ms\n    iterations...........: 1   15.292228/s\n```\n\n## See also\n\n- [Load Testing SQL Databases with k6](https://k6.io/blog/load-testing-sql-databases-with-k6/)\n\n### Support for other RDBMSs\n\nNote that this project is not accepting support for additional SQL implementations\nand RDBMSs. See the discussion in [issue #17](https://github.com/grafana/xk6-sql/issues/17)\nfor the reasoning.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaf1980%2Fxk6-sqlx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsaf1980%2Fxk6-sqlx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaf1980%2Fxk6-sqlx/lists"}