Skip to content

Commit d703ae5

Browse files
authored
Make main.go idempotent
Drop table if it exists, allows to run main.go several times.
1 parent b90d3e4 commit d703ae5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/basic/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ func main2() error {
1919
return fmt.Errorf("failed to open database: %v", err)
2020
}
2121
defer conn.Close()
22+
23+
err = conn.Exec(`DROP TABLE if exists student`)
24+
if err != nil {
25+
return fmt.Errorf("failed to drop students table: %v", err)
26+
}
2227

2328
err = conn.Exec(`CREATE TABLE student(name STRING, age INTEGER)`)
2429
if err != nil {

0 commit comments

Comments
 (0)