{"id":13804692,"url":"https://github.com/huntlabs/hunt-database","last_synced_at":"2025-10-26T17:31:33.728Z","repository":{"id":48177583,"uuid":"95102625","full_name":"huntlabs/hunt-database","owner":"huntlabs","description":"Database abstraction layer library using pure D programing language, support PostgreSQL and MySQL.","archived":false,"fork":false,"pushed_at":"2023-11-15T08:15:53.000Z","size":5926,"stargazers_count":48,"open_issues_count":21,"forks_count":5,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-31T21:53:00.313Z","etag":null,"topics":["database","dlang","mysql","native","postgresql","sqlite"],"latest_commit_sha":null,"homepage":"https://www.huntlabs.net","language":"D","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/huntlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-22T10:11:45.000Z","updated_at":"2024-08-28T22:26:14.000Z","dependencies_parsed_at":"2024-01-03T01:30:19.962Z","dependency_job_id":null,"html_url":"https://github.com/huntlabs/hunt-database","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huntlabs%2Fhunt-database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huntlabs%2Fhunt-database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huntlabs%2Fhunt-database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huntlabs%2Fhunt-database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huntlabs","download_url":"https://codeload.github.com/huntlabs/hunt-database/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375246,"owners_count":19461571,"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":["database","dlang","mysql","native","postgresql","sqlite"],"created_at":"2024-08-04T01:00:52.688Z","updated_at":"2025-10-26T17:31:33.340Z","avatar_url":"https://github.com/huntlabs.png","language":"D","readme":"[![Build Status](https://travis-ci.org/huntlabs/hunt-database.svg?branch=master)](https://travis-ci.org/huntlabs/hunt-database)\r\n\r\n## Database\r\nDatabase abstraction layer for D programing language, support PostgreSQL / MySQL.\r\n\r\n## Example\r\n```D\r\n\r\nimport std.stdio;\r\n\r\nimport hunt.database;\r\n\r\nvoid main()\r\n{\r\n    writeln(\"run database MySQL demo.\");\r\n\r\n    auto db = new Database(\"mysql://root:123456@localhost:3306/test?charset=utf8mb4\");\r\n\r\n    int result = db.execute(`INSERT INTO user(username) VALUES(\"test\")`);\r\n    writeln(result);\r\n\r\n    foreach(row; db.query(\"SELECT * FROM user LIMIT 10\"))\r\n    {\r\n        writeln(row[\"username\"]);\r\n    }\r\n\r\n    db.close();\r\n}\r\n\r\n```\r\n\r\n## Use DatabaseOption to instantiate a Database object\r\n```D\r\nauto options = new DatabaseOption(\"mysql://root:123456@localhost:3306/test\");\r\noptions.setMaximumConnection(5);\r\n\r\nauto db = new Database(options);\r\n\r\ndb.execute(\"SET NAMES utf8\");\r\n```\r\n\r\n## API\r\n\r\n-  int Database.execute(string sql)  Return number of execute result.\r\n```D\r\nint result = db.execute('INSERT INTO user(username) VALUES(\"Brian\")');\r\n// if execute error ,db will throw an DatabaseException\r\n```\r\n-  RowSet Database.query(sql) Return RowSet object for query(SELECT).\r\n```D\r\nRowSet rs = db.query(\"SELECT * FROM user LIMIT 10\");\r\n```\r\n-  Statement Database.prepare(sql) Create a prepared Statement object.\r\n```D\r\nStatement stmt = db.prepare(\"SELECT * FROM user where username = :username and age = :age LIMIT 10\");\r\n```\r\n- Statement.setParameter(param, value) : bind param's value to :param for sql.\r\n```D\r\nstmt.setParameter(\"username\", \"viile\");\r\nstmt.setParameter(\"age\", 18);\r\n```\r\n- RowSet Statement.query()  Return RowSet \r\n```D\r\nRowSet rs = stmt.query();\r\nforeach(row; rs)\r\n{\r\n    writeln(row[\"username\"]);\r\n}\r\n```\r\n- Row Statement.fetch()  Return Row \r\n```D\r\nRow row = stmt.fetch();\r\nwriteln(row[\"username\"]);\r\n```\r\n- int Statement.execute() : return execute status for prepared Statement object. \r\n```D\r\nint result = stmt.execute();\r\n```\r\n- Statement.lastInsertId() : Statement.execute() for insert sql, return lastInsertId.\r\n\r\n\r\n### See also\r\n- https://github.com/eclipse-vertx/vertx-sql-client","funding_links":[],"categories":["Database clients"],"sub_categories":["XML"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuntlabs%2Fhunt-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuntlabs%2Fhunt-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuntlabs%2Fhunt-database/lists"}