-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from dolthub/fulghum/dev
Feature: Add support for multiple result sets through the `driver.RowsNextResultSet` interface
- Loading branch information
Showing
9 changed files
with
720 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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()) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.