1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sqlite: create_table()

This commit is contained in:
Alexander Medvednikov 2021-01-20 09:30:26 +01:00
parent 57af8570fe
commit 158aefc37f
2 changed files with 7 additions and 5 deletions

View File

@ -455,13 +455,11 @@ s := r'hello\nworld'
println(s) // "hello\nworld" println(s) // "hello\nworld"
``` ```
Strings can be easily converted to number types: Strings can be easily converted to integers:
```v ```v
s := '42' s := '42'
n := s.int() // 42 n := s.int() // 42
b := s.byte()
u := s.u32()
``` ```
### String interpolation ### String interpolation
@ -3216,7 +3214,7 @@ it easier to change in external editor programs, without needing to recompile
your executable. your executable.
When you compile with `-prod`, the file *will be embedded inside* your 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 thus easier to distribute. In this case, `f.data()` will cause *no IO*,
and it will always return the same data. and it will always return the same data.

View File

@ -23,7 +23,7 @@ pub struct DB {
pub mut: pub mut:
is_open bool is_open bool
mut: mut:
conn &C.sqlite3 conn &C.sqlite3
} }
pub fn (db DB) str() string { 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<T>(x T) { pub fn (db DB) insert<T>(x T) {
} }
pub fn (db DB) create_table(table_name string, rows []string) {
db.exec('create table $table_name (' + rows.join(',\n') + ')')
}