{"id":17061613,"url":"https://github.com/paxa/mysql.d","last_synced_at":"2025-10-23T16:28:23.015Z","repository":{"id":136211009,"uuid":"20911408","full_name":"Paxa/mysql.d","owner":"Paxa","description":"mysql library binding for D programming language","archived":false,"fork":false,"pushed_at":"2019-07-27T17:50:14.000Z","size":65,"stargazers_count":18,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-28T15:16:20.726Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"D","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/Paxa.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","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}},"created_at":"2014-06-17T05:29:42.000Z","updated_at":"2024-07-28T01:51:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"c6f73120-b6e6-4f1a-a2d0-294adafec3da","html_url":"https://github.com/Paxa/mysql.d","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fmysql.d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fmysql.d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fmysql.d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Fmysql.d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Paxa","download_url":"https://codeload.github.com/Paxa/mysql.d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245074404,"owners_count":20556749,"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":[],"created_at":"2024-10-14T10:47:37.783Z","updated_at":"2025-10-23T16:28:22.954Z","avatar_url":"https://github.com/Paxa.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mysql.d\n\n### mysql library binding. Extraction from https://github.com/adamdruppe/arsd\n\n[![Build Status](https://travis-ci.org/Paxa/mysql.d.svg?branch=master)](https://travis-ci.org/Paxa/mysql.d)\n\nDocumentation is not ready yet\n\n```D\nimport std.stdio;\nimport mysql.d;\n\nvoid main() {\n    auto mysql = new Mysql(\"localhost\", 3306, \"root\", \"root\", \"mysql_d_testing\");\n\n    mysql.query(\"DROP TABLE IF EXISTS users\");\n    mysql.query(\"CREATE TABLE users (\n        id INT NOT NULL AUTO_INCREMENT,\n        name VARCHAR(100),\n        sex tinyint(1) DEFAULT NULL,\n        birthdate DATE,\n        PRIMARY KEY (id)\n    );\");\n\n    mysql.query(\"insert into users (name, sex, birthdate) values (?, ?, ?);\", \"Paul\", 1, \"1981-05-06\");\n    mysql.query(\"insert into users (name, sex, birthdate) values (?, ?, ?);\", \"Anna\", 0, \"1983-02-13\");\n\n    auto rows = mysql.query(\"select * from users\");\n\n    rows.length; // =\u003e 2\n    foreach (user; rows) {\n        writefln(\"User %s, %s, born on %s\", user[\"name\"], user[\"sex\"] == \"1\" ? \"male\" : \"female\", user[\"birthdate\"]);\n    }\n\n    bool result = mysql.exec(\"select name, gender from users\");\n    if (!result) {\n      writefln(\"SQL Error: %s\", mysql.dbErrorMsg);\n    }\n}\n```\n\nOutput is:\n```\nUser Paul, male, born on 1981-05-06\nUser Anna, female, born on 1983-02-13\n```\n\n**Escaping**\n\n    ? - convert to string with escaped quotes to prevent sql injection\n    `?` - convert to string but without quotes\n\n```d\nmysql.query(\"DROP TABLE ?\", \"table_name\"); // error\n// SQL error near near ''table_name'' at line 1 :::: DROP TABLE 'table_name'\n// should be `some_table` not 'some_table'\n\nmysql.query(\"DROP TABLE `?`\", \"table_name\"); // working\n```\n\n#### Compiling\n\n* Install dub with `brew install dub` or from here http://code.dlang.org/download\n* Run `dub`\n\n#### Testing\n\n* run `dub test --config=test`\n\n#### Example application\n\n[http://mysql-d.tk/](http://mysql-d.tk/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxa%2Fmysql.d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaxa%2Fmysql.d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxa%2Fmysql.d/lists"}