Skip to content

Commit

Permalink
Updating README with new section on multistatement support
Browse files Browse the repository at this point in the history
  • Loading branch information
fulghum committed Jul 9, 2024
1 parent 7fda060 commit e1ee3f6
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cd dbs
dolt clone <REMOTE URL>
```

Finally you can create the dbs directory as shown above and then create the database in code using a SQL `CREATE TABLE` statement
Finally, you can create the dbs directory as shown above and then create the database in code using a SQL `CREATE TABLE` statement

### Connecting to the Database

Expand Down Expand Up @@ -61,3 +61,31 @@ clientfoundrows - If set to true, returns the number of matching rows instead of
#### Example DSN

`file:///path/to/dbs?commitname=Your%20Name&[email protected]&database=databasename`

### Multi-Statement Support

If you pass the `multistatements=true` parameter in the DSN, you can execute multiple statements in one query. The returned
rows allow you to iterate over the returned result sets by using the `NextResultSet` method, just like you can with the
MySQL driver.

```go
rows, err := db.Query("SELECT * from someTable; SELECT * from anotherTable;")
// If an error is returned, it means it came from the first statement
if err != nil {
panic(err)
}

for rows.Next() {
// process the first result set
}

if rows.NextResultSet() {
for rows.Next() {
// process the second result set
}
} else {
// If NextResultSet returns false when there were more statements, it means there was an error,
// which you can access through rows.Err()
panic(rows.Err())
}
```

0 comments on commit e1ee3f6

Please sign in to comment.