Skip to content

Commit 194974a

Browse files
committed
example code creates table
1 parent 9c1cee0 commit 194974a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/homePage/example.d

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ void main(string[] args)
1111
Connection conn = new Connection(connectionStr);
1212
scope(exit) conn.close();
1313

14-
// Insert
15-
ulong rowsAffected = conn.exec(
16-
"INSERT INTO `tablename` (`id`, `name`) VALUES (1, 'Ann'), (2, 'Bob')");
14+
// Create the schema
15+
conn.exec("CREATE TABLE IF NOT EXISTS `tablename` (
16+
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
17+
`name` VARCHAR(250)
18+
)");
19+
20+
// Insert Some Test Data
21+
ulong rowsAffected = conn.exec("INSERT INTO `tablename` (`id`, `name`) VALUES (1, 'Ann'), (2, 'Bob')");
1722

1823
// Query
1924
ResultRange range = conn.query("SELECT * FROM `tablename`");

0 commit comments

Comments
 (0)