From 158aefc37f1caca7640d0e5bee9b764dd3fb1f08 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 20 Jan 2021 09:30:26 +0100 Subject: [PATCH] sqlite: create_table() --- doc/docs.md | 6 ++---- vlib/sqlite/sqlite.v | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 027c161f02..a19bbbe1ed 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -455,13 +455,11 @@ s := r'hello\nworld' println(s) // "hello\nworld" ``` -Strings can be easily converted to number types: +Strings can be easily converted to integers: ```v s := '42' n := s.int() // 42 -b := s.byte() -u := s.u32() ``` ### String interpolation @@ -3216,7 +3214,7 @@ it easier to change in external editor programs, without needing to recompile your executable. When you compile with `-prod`, the file *will be embedded inside* your -executable, increasing your binary size, but making it more self contained +executable, increasing your binary size, but making it more self contained and thus easier to distribute. In this case, `f.data()` will cause *no IO*, and it will always return the same data. diff --git a/vlib/sqlite/sqlite.v b/vlib/sqlite/sqlite.v index cdededad73..5248bbfdc2 100644 --- a/vlib/sqlite/sqlite.v +++ b/vlib/sqlite/sqlite.v @@ -23,7 +23,7 @@ pub struct DB { pub mut: is_open bool mut: - conn &C.sqlite3 + conn &C.sqlite3 } pub fn (db DB) str() string { @@ -178,3 +178,7 @@ pub fn (db DB) exec_param(query string, param string) []Row { */ pub fn (db DB) insert(x T) { } + +pub fn (db DB) create_table(table_name string, rows []string) { + db.exec('create table $table_name (' + rows.join(',\n') + ')') +}