{"id":37118126,"url":"https://github.com/viemacs/dal","last_synced_at":"2026-01-14T13:48:27.724Z","repository":{"id":57531413,"uuid":"240888200","full_name":"viemacs/dal","owner":"viemacs","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-03T14:10:38.000Z","size":19,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T14:19:26.276Z","etag":null,"topics":["database-access"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/viemacs.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}},"created_at":"2020-02-16T12:33:24.000Z","updated_at":"2024-06-20T14:19:26.277Z","dependencies_parsed_at":"2022-09-06T17:21:55.832Z","dependency_job_id":null,"html_url":"https://github.com/viemacs/dal","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/viemacs/dal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viemacs%2Fdal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viemacs%2Fdal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viemacs%2Fdal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viemacs%2Fdal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viemacs","download_url":"https://codeload.github.com/viemacs/dal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viemacs%2Fdal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"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":["database-access"],"created_at":"2026-01-14T13:48:27.204Z","updated_at":"2026-01-14T13:48:27.704Z","avatar_url":"https://github.com/viemacs.png","language":"Go","readme":"DAL\n===\n\nDAL provides a Database Access Layer in Go for MySQL.\n\n## Requirements\n- Go 1.10 or higher\n- MySQL(4.1+) or MariaDB\n\n## Installation\nThis package can be installed with the go get command.\n\n``` go\ngo get github.com/viemacs/dal\n```\n\n## API Reference\nExamples can be found in the test file.\n\nA model should be initialized first with connection options.\n\n- Initialize a Model of MySQL.\n\n``` go\nmodel := Model{\n    DriverName:     \"mysql\",\n    DataSourceName: \"user:password@tcp(hostIP)/database\",\n}\n```\n\n- Write values to database.\n\n``` go\ntype T struct {\n     ID int `field:\"id\"`\n}\nvalues := []T{{1}}\nif err := model.Write(\"tableName\", values); err != nil {\n\tdealWithError(err)\n}\n```\n\n- Read records from database.\n\n``` go\nif err := model.Read(\"tablename\", []string{\"id\"}, \"\", T{}); err != nil {\n\tdealWithError(err)\n}\nfor _, v := range model.Records {\n    handleRecord(v.(T))\n}\n```\n\n- Get version of database.\n\n``` go\nif info := model.DBInfo(); len(info) != 1 {\n\tdealWithError(err)\n}\n```\n\n## Features\n- supports nested structs; does not support array/slice/map as struct fields\n- supports single query; does not support multiple result sets\n\nProgram with fail with panic if the connection to database cannot be established. The caller of this module can recover properly.\n\n## Todo\n1. check type of parameter `values` in Write()\n2. `Read` function skips passing query fields, or match query results with fields of struct.\n3. Support values of nested struct in `Read` function.\n\n## Issue\n1. `Exec` accepts normal interface, but currently values are all printed into strings.\n\n## TBConfirm\n1. sumRowsAffected: are records in database changed before tx.commit() ?\n\n## Notice\n1. Values of nested struct with duplicated fields are not supported yet.\n   During writing, the duplicated fields will generate duplicated fields in SQL.\n   During reading, only the first one of the duplicated fields will be filled.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviemacs%2Fdal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviemacs%2Fdal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviemacs%2Fdal/lists"}