{"id":15066772,"url":"https://github.com/sbstnerhrdt/go-gorm-all-sql","last_synced_at":"2026-01-30T01:15:48.079Z","repository":{"id":57545026,"uuid":"292888266","full_name":"SbstnErhrdt/go-gorm-all-sql","owner":"SbstnErhrdt","description":"generic sql connector for the grom framework","archived":false,"fork":false,"pushed_at":"2023-01-29T18:17:20.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T16:13:01.398Z","etag":null,"topics":["connector","databases","golang","gorm","mysql","postgres","sql","sqlite"],"latest_commit_sha":null,"homepage":"","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/SbstnErhrdt.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-09-04T15:52:43.000Z","updated_at":"2022-03-04T16:51:06.000Z","dependencies_parsed_at":"2023-02-16T00:31:05.435Z","dependency_job_id":null,"html_url":"https://github.com/SbstnErhrdt/go-gorm-all-sql","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SbstnErhrdt%2Fgo-gorm-all-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SbstnErhrdt%2Fgo-gorm-all-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SbstnErhrdt%2Fgo-gorm-all-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SbstnErhrdt%2Fgo-gorm-all-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SbstnErhrdt","download_url":"https://codeload.github.com/SbstnErhrdt/go-gorm-all-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822311,"owners_count":20353496,"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":["connector","databases","golang","gorm","mysql","postgres","sql","sqlite"],"created_at":"2024-09-25T01:12:01.013Z","updated_at":"2026-01-30T01:15:48.018Z","avatar_url":"https://github.com/SbstnErhrdt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gorm - Connect to all databases (Work in Progress)\n\nThis is a generic connector interface for the following databases:\n\n* MySQL\n* Postgres\n* SQLite\n\nWith this connector, it is easy to run your sql based golang software, written with the gorm.io framework, on different\ndatabases, by only changing one environment variable.\n\nJust set `SQL_TYPE` to either `MYSQL`, `POSTGRES`, `SQLITE` and you are good to go.\n\n## Installation\n\n```shell\ngo get github.com/SbstnErhrdt/go-gorm-all-sql\n```\n\nIn a development setting you can make use of the `env` package to load variables from a .env file into the ENV.\n\n```shell\ngo get github.com/SbstnErhrdt/env\n```\n\n## Examples\n\n```go\npackage main\n\nimport (\n\t\"github.com/SbstnErhrdt/go-gorm-all-sql/pkg/sql\"\n)\n\nfunc main() {\n\t// load env\n\tenv.LoadEnvFiles() // reads the .env file in the working directory\n\t// connect to DB\n\tdb, err := sql.ConnectToDatabase()\n}\n```\n\n## Todo\n\n* Tests\n* Docker compose environment\n\n## MySQL\n\nEnv variables\n\n```\nSQL_TYPE=MYSQL\nSQL_HOST=mysql.server.com\nSQL_PORT=3306\nSQL_USER=sql_user\nSQL_PASSWORD=xxxxxx\nSQL_DATABASE=test\n```\n\n## Postgres\n\n```\nSQL_TYPE=POSTGRES\nSQL_HOST=postgres.server.com\nSQL_PORT=5432\nSQL_USER=sql_user\nSQL_PASSWORD=xxxxxx\nSQL_DATABASE=test\nSQL_SSL= // optional\n```\n\n## SQLite\n\n```\nSQL_TYPE=SQLITE\nSQL_DATABASE=data.db\n```\n\n## Logger\n\nto add the logrus logger, add the following environment flag\n\n```\nSQL_LOGGER=LOGRUS\n```\n\n## Functionality\n\n* Works with different SQL dialects\n* Checks if necessary environment variables are present\n* Retries multiple times, if there is no connection available\n\n## Test\n\n### MySQL\n\n```\ndocker-compose run --rm\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstnerhrdt%2Fgo-gorm-all-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbstnerhrdt%2Fgo-gorm-all-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstnerhrdt%2Fgo-gorm-all-sql/lists"}