{"id":42701345,"url":"https://github.com/storage-lock/go-sqlserver-storage","last_synced_at":"2026-01-29T14:20:13.735Z","repository":{"id":186482247,"uuid":"674638346","full_name":"storage-lock/go-sqlserver-storage","owner":"storage-lock","description":"以SqlServer为存储引擎的Storage实现，当前仓库为比较底层的存储层实现，你可以与storage-lock结合使用。","archived":false,"fork":false,"pushed_at":"2023-09-16T18:38:08.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-27T17:05:47.516Z","etag":null,"topics":["sqlserver","storage"],"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/storage-lock.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}},"created_at":"2023-08-04T12:37:01.000Z","updated_at":"2023-08-08T16:31:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a14bb4f-1f5a-4efa-b0e9-bf9f1da97dd5","html_url":"https://github.com/storage-lock/go-sqlserver-storage","commit_stats":{"total_commits":15,"total_committers":3,"mean_commits":5.0,"dds":0.1333333333333333,"last_synced_commit":"f1cfe0b4cf50a2d8c5a6e2f9de4068388e7893bb"},"previous_names":["storage-lock/go-sqlserver-storage"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/storage-lock/go-sqlserver-storage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-lock%2Fgo-sqlserver-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-lock%2Fgo-sqlserver-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-lock%2Fgo-sqlserver-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-lock%2Fgo-sqlserver-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/storage-lock","download_url":"https://codeload.github.com/storage-lock/go-sqlserver-storage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storage-lock%2Fgo-sqlserver-storage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28879331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["sqlserver","storage"],"created_at":"2026-01-29T14:20:12.664Z","updated_at":"2026-01-29T14:20:13.701Z","avatar_url":"https://github.com/storage-lock.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SqlServer Storage\n\n# 一、这是什么\n以SqlServer为存储引擎的[Storage](https://github.com/storage-lock/go-storage)实现，当前仓库为比较底层的存储层实现，你可以与[storage-lock](https://github.com/storage-lock/go-storage-lock)结合使用。\n\n# 二、安装依赖\n```bash\ngo get -u github.com/storage-lock/go-sqlserver-storage \n```\n\n# 三、API Examples\n\n## 3.1 从DSN创建SqlServerStorage\n\n在Golang的世界中连接数据库最常见的就是DSN，下面的例子演示了如何从一个DSN创建SqlServerStorage：\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\tsqlserver_storage \"github.com/storage-lock/go-sqlserver-storage\"\n)\n\nfunc main() {\n\n\t// 使用一个DSN形式的数据库连接字符串创建ConnectionManager\n\ttestDsn := \"sqlserver://sa:UeGqAm8CxYGldMDLoNNt@127.0.0.1:1433?database=storage_lock_test\u0026connection+timeout=30\"\n\tconnectionManager := sqlserver_storage.NewSqlServerConnectionManagerFromDSN(testDsn)\n\n\t// 然后从这个ConnectionManager创建SqlServer Storage\n\toptions := sqlserver_storage.NewSqlServerStorageOptions().SetConnectionManager(connectionManager)\n\tstorage, err := sqlserver_storage.NewSqlServerStorage(context.Background(), options)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(storage.GetName())\n\n}\n```\n\n## 3.2 从连接属性（ip、端口、用户名、密码等等）中创建SqlServerStorage\n\n或者你的配置文件中存放的并不是DSN，而是零散的几个连接属性，下面是一个创建SqlServerStorage的例子：\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\tsqlserver_storage \"github.com/storage-lock/go-sqlserver-storage\"\n)\n\nfunc main() {\n\n\t// 数据库连接不是DSN的形式，就是一堆零散的属性，则依次设置，可以得到一个连接管理器\n\thost := \"127.0.0.1\"\n\tport := uint(1433)\n\tusername := \"root\"\n\tpasswd := \"UeGqAm8CxYGldMDLoNNt\"\n\tconnectionManager := sqlserver_storage.NewSqlServerConnectionManager(host, port, username, passwd)\n\n\t// 然后从这个连接管理器创建SqlServer Storage\n\toptions := sqlserver_storage.NewSqlServerStorageOptions().SetConnectionManager(connectionManager)\n\tstorage, err := sqlserver_storage.NewSqlServerStorage(context.Background(), options)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(storage.GetName())\n\n}\n```\n\n## 3.3 从sql.DB创建SqlServerStorage\n\n或者现在你已经有从其它渠道创建的能够连接到SqlServer的sql.DB，则也可以从这个*sql.DB创建SqlServerStorage：\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"fmt\"\n\tsqlserver_storage \"github.com/storage-lock/go-sqlserver-storage\"\n\tstorage \"github.com/storage-lock/go-storage\"\n)\n\nfunc main() {\n\n\t// 假设已经在其它地方初始化数据库连接得到了一个*sql.DB\n\ttestDsn := \"sqlserver://sa:UeGqAm8CxYGldMDLoNNt@127.0.0.1:1433?database=storage_lock_test\u0026connection+timeout=30\"\n\tdb, err := sql.Open(\"mssql\", testDsn)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// 则可以从这个*sql.DB中创建一个SqlServer Storage\n\tconnectionManager := storage.NewFixedSqlDBConnectionManager(db)\n\toptions := sqlserver_storage.NewSqlServerStorageOptions().SetConnectionManager(connectionManager)\n\tstorage, err := sqlserver_storage.NewSqlServerStorage(context.Background(), options)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(storage.GetName())\n\n}\n```\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstorage-lock%2Fgo-sqlserver-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstorage-lock%2Fgo-sqlserver-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstorage-lock%2Fgo-sqlserver-storage/lists"}