{"id":18266819,"url":"https://github.com/chenquan/sqlbreaker","last_synced_at":"2025-04-04T22:30:31.207Z","repository":{"id":59696592,"uuid":"536558622","full_name":"chenquan/sqlbreaker","owner":"chenquan","description":"A low-code intrusion library that provides SQL breaker capabilities, suitable for any relational database (Sqlite3, MySQL, Oracle, SQL Server, PostgreSQL, TiDB, TDengine, etc.) and ORM libraries for various relational database (gorm, xorm, sqlx, ent, etc.)","archived":false,"fork":false,"pushed_at":"2024-11-28T00:17:44.000Z","size":202,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T20:14:01.045Z","etag":null,"topics":["breaker","ent","go","golang","gorm","mysql","oracle","orm","postgres","postgresql","sql","sqlite3","sqlserver","tidb","xorm","xsql"],"latest_commit_sha":null,"homepage":"","language":"Go","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/chenquan.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-14T12:04:31.000Z","updated_at":"2024-11-28T00:17:40.000Z","dependencies_parsed_at":"2024-03-01T22:48:05.513Z","dependency_job_id":null,"html_url":"https://github.com/chenquan/sqlbreaker","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":"0.11764705882352944","last_synced_commit":"35db3aa4f3fec68809ccb51c810c8eb236693fcf"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fsqlbreaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fsqlbreaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fsqlbreaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fsqlbreaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenquan","download_url":"https://codeload.github.com/chenquan/sqlbreaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247260215,"owners_count":20909957,"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":["breaker","ent","go","golang","gorm","mysql","oracle","orm","postgres","postgresql","sql","sqlite3","sqlserver","tidb","xorm","xsql"],"created_at":"2024-11-05T11:24:58.886Z","updated_at":"2025-04-04T22:30:30.405Z","avatar_url":"https://github.com/chenquan.png","language":"Go","readme":"# sqlbreaker\n\n[![Godoc](https://img.shields.io/badge/godoc-reference-brightgreen)](https://pkg.go.dev/github.com/chenquan/sqlbreaker)\n[![Go Report Card](https://goreportcard.com/badge/github.com/chenquan/sqlbreaker)](https://goreportcard.com/report/github.com/chenquan/sqlbreaker)\n[![Release](https://img.shields.io/github/v/release/chenquan/sqlbreaker.svg?style=flat-square)](https://github.com/chenquan/sqlbreaker)\n[![codecov](https://codecov.io/gh/chenquan/sqlbreaker/branch/master/graph/badge.svg?token=74phc5KVI7)](https://codecov.io/gh/chenquan/sqlbreaker)\n[![Download](https://goproxy.cn/stats/github.com/chenquan/sqlbreaker/badges/download-count.svg)](https://github.com/chenquan/sqlbreaker)\n[![GitHub](https://img.shields.io/github/license/chenquan/sqlbreaker)](https://github.com/chenquan/sqlbreaker/blob/master/LICENSE)\n\nA low-code intrusion library that provides SQL breaker capabilities, suitable for any relational database (Sqlite3, MySQL, Oracle, SQL Server,\nPostgreSQL, TiDB, TDengine, etc.) and ORM libraries for various relational database (gorm, xorm, sqlx, etc.)\n\n\u003e Unstable, use with caution in production environment\n\n# 😜installation\n\n```shell\ngo get -u github.com/chenquan/sqlbreaker\n```\n\n# 👏how to use\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"fmt\"\n\n\t\"github.com/chenquan/sqlbreaker\"\n\t\"github.com/chenquan/sqlbreaker/pkg/breaker\"\n\t\"github.com/chenquan/sqlplus\"\n\t\"github.com/chenquan/sqltrace\"\n\t\"github.com/mattn/go-sqlite3\"\n\t\"go.opentelemetry.io/otel\"\n\t\"go.opentelemetry.io/otel/trace\"\n)\n\nfunc main() {\n\t// Create a sqlite3 driver with tracing and  breaker\n\thook := sqlplus.NewMultiHook(\n\t\tsqltrace.NewTraceHook(sqltrace.Config{\n\t\t\tName:           \"sqlite3_trace\",\n\t\t\tDataSourceName: \"sqlite3\",\n\t\t\tEndpoint:       \"http://localhost:14268/api/traces\",\n\t\t\tSampler:        1,\n\t\t\tBatcher:        \"jaeger\",\n\t\t}),\n\t\tsqlbreaker.NewBreakerHook(breaker.NewBreaker()),\n\t)\n\n\t// register new driver\n\tsql.Register(\"sqlite3_trace\", sqlplus.New(\u0026sqlite3.SQLiteDriver{}, hook))\n\tdefer sqltrace.StopAgent()\n\n\t// open database\n\tdb, err := sql.Open(\"sqlite3_trace\", \"identifier.sqlite\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttracer := otel.GetTracerProvider().Tracer(\"sqlite3_trace\")\n\tctx, span := tracer.Start(context.Background(),\n\t\t\"test\",\n\t\ttrace.WithSpanKind(trace.SpanKindClient),\n\t)\n\tdefer span.End()\n\n\tdb.ExecContext(ctx, `CREATE TABLE  IF NOT EXISTS t\n(\n    age  integer,\n    name TEXT\n)`)\n\tdb.ExecContext(ctx, \"insert into t values (?,?)\", 1, \"chenquan\")\n\n\t// transaction\n\ttx, err := db.BeginTx(ctx, nil)\n\tstmt, err := tx.PrepareContext(ctx, \"select age+1 as age,name from t where age = ?;\")\n\tstmt.QueryContext(ctx, 1)\n\ttx.Commit()\n\n\trows, err := db.QueryContext(ctx, \"select  age+1 as age,name from t;\")\n\tfor rows.Next() {\n\t\tvar age int\n\t\tvar name string\n\t\terr := rows.Scan(\u0026age, \u0026name)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\tfmt.Println(age, name)\n\t}\n}\n\n```\n\n![](images/trace-native.png)\n\n# ⭐star\n\nIf you like or are using this project to learn or start your solution, please give it a star⭐. Thanks!\n\n# 👐ecosystem\n\n- [sqltrace](https://github.com/chenquan/sqltrace):A low-code intrusion library that provides SQL tracing capabilities, suitable for any\n  relational database (Sqlite3, MySQL, Oracle, SQL Server, PostgreSQL, TiDB, TDengine, etc.) and ORM libraries for various\n  relational database (gorm, xorm, sqlx, etc.)\n- [sqlplus](https://github.com/chenquan/sqlplus): A sql enhancement tool library based on `database/sql/driver`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenquan%2Fsqlbreaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenquan%2Fsqlbreaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenquan%2Fsqlbreaker/lists"}