Skip to content

Commit b7e9b6d

Browse files
committed
minor README fixes
1 parent 1f55645 commit b7e9b6d

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2 align="center">sqlz</h2>
2-
<p align="center">flexible SQL query builder for Go.</p>
2+
<p align="center">Flexible SQL query builder for Go</p>
33
<p align="center">
44
<a href="https://godoc.org/github.com/ido50/sqlz"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"></a>
55
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
@@ -9,22 +9,22 @@
99

1010
---
1111

12-
sqlz (pronounced "sequelize") is an un-opinionated, un-obtrusive SQL query builder for Go projects, based on [sqlx](https://github.com/jmoiron/sqlx/).
12+
**sqlz** (pronounced "sequelize") is an un-opinionated, un-obtrusive SQL query builder for Go projects, based on [sqlx](https://github.com/jmoiron/sqlx/).
1313

1414
As opposed to other query builders, sqlz does not mean to bridge the gap between different SQL servers and implementations by
1515
providing a unified interface. Instead, it aims to support an extended SQL syntax that may be implementation-specific. For
1616
example, if you wish to use PostgreSQL-specific features such as JSON operators and upsert statements, sqlz means to support
1717
these without caring if the underlying database backend really is PostgreSQL. In other words, sqlz builds whatever queries
1818
you want it to build.
1919

20-
sqlz is easy to integrate into existing code, as it does not require you to create your database connections through the
21-
sqlz API; in fact, it doesn't supply one. You can either use your existing `*sql.DB` connection or an `*sqlx.DB` connection,
20+
**sqlz** is easy to integrate into existing code, as it does not require you to create your database connections through the
21+
**sqlz** API; in fact, it doesn't supply one. You can either use your existing `*sql.DB` connection or an `*sqlx.DB` connection,
2222
so you can start writing new queries with sqlz without having to modify any existing code.
2323

24-
sqlz leverages sqlx for easy loading of query results. Please make sure you are familiar with [how sqlx works](https://jmoiron.github.io/sqlx/)
24+
**sqlz** leverages **sqlx** for easy loading of query results. Please make sure you are familiar with [how sqlx works](https://jmoiron.github.io/sqlx/)
2525
in order to understand how row scanning is performed. You may need to add `db` struct tags to your Go structures.
2626

27-
sqlz provides a comfortable API for running queries in a transaction, and will automatically commit or rollback the
27+
**sqlz** provides a comfortable API for running queries in a transaction, and will automatically commit or rollback the
2828
transaction as necessary.
2929

3030
## Install
@@ -38,7 +38,7 @@ go get -u github.com/ido50/sqlz
3838
Once installed, you can import sqlz into your Go packages. To build and execute queries with
3939
sqlz, you need to pass the underlying `*sql.DB` or `*sqlx.DB` objects. If using `database/sql`,
4040
you'll need to tell sqlz the name of the driver (so that it knows which placeholders to use
41-
when building queries); if using `jmoiron/sqlx`, this is not necessary.
41+
when building queries); if using `github.com/jmoiron/sqlx`, this is not necessary.
4242

4343
```go
4444
package main
@@ -240,22 +240,30 @@ sqlz.
240240
New(db, driver).
241241
Transactional(func(tx *sqlz.Tx) error {
242242
var id int64
243-
err := tx.InsertInto("table").Columns("name").Values("some guy").GetRow(&id)
243+
err := tx.
244+
InsertInto("table").
245+
Columns("name").
246+
Values("some guy").
247+
Returning("id").
248+
GetRow(&id)
244249
if err != nil {
245-
return err
250+
return fmt.Errorf("failed inserting row: %w", err)
246251
}
247252

248-
_, err = tx.Update("other-table").Set("some-col", 4).Exec()
253+
_, err = tx.
254+
Update("other-table").
255+
Set("some-col", 4).
256+
Exec()
249257
if err != nil {
250-
return err
258+
return fmt.Errorf("failed updating row: %w", err)
251259
}
252260

253261
return nil
254262
})
255263
```
256264

257-
If the function provided to the Transactional method returns an error, the transaction
258-
will be rolled back. Otherwise, it will be committed.
265+
If the function provided to the `Transactional` method returns an error, the
266+
transaction will be rolled back. Otherwise, it will be committed.
259267

260268
### Using strings as-is in queries
261269

0 commit comments

Comments
 (0)