{"id":16445488,"url":"https://github.com/stephenafamo/fakedb","last_synced_at":"2025-07-09T08:04:45.677Z","repository":{"id":53836106,"uuid":"521622673","full_name":"stephenafamo/fakedb","owner":"stephenafamo","description":"fakedb registers a fake database driver named test for... testing.","archived":false,"fork":false,"pushed_at":"2022-12-30T08:20:02.000Z","size":23,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T06:15:21.286Z","etag":null,"topics":["database","fake","faker","go","golang","sql","test","testing","testing-tools"],"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/stephenafamo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-05T12:03:59.000Z","updated_at":"2024-06-29T14:08:04.000Z","dependencies_parsed_at":"2023-01-31T10:50:19.944Z","dependency_job_id":null,"html_url":"https://github.com/stephenafamo/fakedb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stephenafamo/fakedb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenafamo%2Ffakedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenafamo%2Ffakedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenafamo%2Ffakedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenafamo%2Ffakedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenafamo","download_url":"https://codeload.github.com/stephenafamo/fakedb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenafamo%2Ffakedb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264419452,"owners_count":23605197,"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","fake","faker","go","golang","sql","test","testing","testing-tools"],"created_at":"2024-10-11T09:44:35.622Z","updated_at":"2025-07-09T08:04:45.658Z","avatar_url":"https://github.com/stephenafamo.png","language":"Go","readme":"# FakeDB\n\nThis is copied from \u003chttp://golang.org/src/pkg/database/sql/fakedb_test.go\u003e\n\nIt registers a fake database driver named `test`, just for testing.\n\nIt speaks a query language that's semantically similar to but\nsyntactically different and simpler than SQL.\n\n## Query Methods\n\nThe query syntax is as follows\n\n        WIPE\n        CREATE|\u003ctablename\u003e|\u003ccol\u003e=\u003ctype\u003e,\u003ccol\u003e=\u003ctype\u003e,...\n        INSERT|\u003ctablename\u003e|col=val,col2=val2,col3=?\n        SELECT|\u003ctablename\u003e|projectcol1,projectcol2|filtercol=?,filtercol2=?\n        SELECT|\u003ctablename\u003e|projectcol1,projectcol2|filtercol=?param1,filtercol2=?param2\n\n* WIPE: Wipes all data in the database, including table information\n\n        WIPE\n\n* CREATE: Creates a new table\n\n        CREATE|tableName|columnName1=columnType1,columnName2=columnType2\n\n* DROP: Drops a table\n\n        DROP|tableName\n\n* INSERT: Inserts a row into a table\n\n        INSERT|tableName|column1=?,column2=?\n\n* SELECT: Queries the table. If the column list is empty, all columns are selected.\n\n        SELECT|tableName|column1,column2|where=?,where2=?named\n\nAny of these can be preceded by `PANIC|\u003cmethod\u003e|`, to cause the\nnamed method on fakeStmt to panic.\n\nAny of these can be proceeded by `WAIT|\u003cduration\u003e|`, to cause the\nnamed method on fakeStmt to sleep for the specified duration.\n\nMultiple of these can be combined when separated with a semicolon.\n\nWhen opening a fakeDriver's database, it starts empty with no\ntables. All tables and data are stored in memory only.\n\n## Placeholders\n\nIn any query, `?` is used to denote a positional placeholder, and `?name` for a named placeholder\n\n## Allowed types\n\n* bool\n* string\n* byte\n* int16\n* int32\n* in64\n* float64\n* datetime\n* any\n\n\u003e **NOTE:** Every type can be nullable using nulltype. E.g nullstring for a nullable string\n\n## Usage\n\nAs seen on [fakedb_test.go](fakedb_test.go)\n\n```go\npackage fakedb_test\n\nimport (\n    \"context\"\n    \"database/sql\"\n    \"testing\"\n\n    _ \"github.com/stephenafamo/fakedb\"\n)\n\nfunc TestQuery(t *testing.T) {\n    ctx := context.Background()\n\n    db, err := sql.Open(\"test\", \"identifier\")\n    if err != nil {\n        t.Fatalf(\"Error opening testdb %v\", err)\n    }\n\n    exec(t, db, \"CREATE|users|id=int64,name=string\")\n    exec(t, db, \"INSERT|users|id=?,name=?\", 1, \"foo\")\n    exec(t, db, \"INSERT|users|id=?,name=?\", 2, \"bar\")\n\n    rows, err := db.QueryContext(ctx, \"SELECT|users|id,name|\")\n    if err != nil {\n        t.Fatal(err)\n    }\n\n    users := []string{\"foo\", \"bar\"}\n    for rows.Next() {\n        var id int\n        var name string\n        rows.Scan(\u0026id, \u0026name)\n\n        expectedName := users[id-1]\n        if name != users[id-1] {\n            t.Fatalf(\"User %d should have name %q but had %q\", id, expectedName, name)\n        }\n    }\n}\n\nfunc exec(tb testing.TB, exec *sql.DB, query string, args ...interface{}) sql.Result {\n    tb.Helper()\n    result, err := exec.ExecContext(context.Background(), query, args...)\n    if err != nil {\n        tb.Fatalf(\"Exec of %q: %v\", query, err)\n    }\n\n    return result\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenafamo%2Ffakedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenafamo%2Ffakedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenafamo%2Ffakedb/lists"}