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OV7BAKSTKWSLAAQJ22PCS2ELDK5SAC
SIC4BVK6MY6CC4NSS6NQDFG7SM7I7LLIRSEGOHESIM2UEDILGVSQC
YC5QGKPJSZ5XGGEKDCYVC52KW6P7QII7HXKP4BTF3MYWFEPNMGKQC
ZIDFZNTT4HZDKKWK25U7OPIFSVTSNTZVEKWCBQ6XEPR3HHSNL2AAC
VSXY63RCAE4WDARTVOW6YDD6VPMRBNASRD73R4UMZDAAQX7MAVTAC
pub fn network_to_db(ircnet Network) []string {
mut ircrow := []string{}
ircrow.push('') // id
ircrow.push(ircnet.hostnames[0])
ircrow.push(ircnet.name) // netname
pub fn network_to_db(ircnet Network) []db.SqlValue {
mut ircrow := []db.SqlValue{}
ircrow.push(db.SqlValue{name:"hostname", value:db.SqlType(ircnet.hostname)})
ircrow.push(db.SqlValue{name:"netname", value:db.SqlType(ircnet.name)})
sql_stmt := 'create table irc_servers (id integer primary key, hostname text, netname text)'
db.exec_one(sql_stmt) or { println('db.sqlite fail $sql_stmt $err') }
return Db{
mut dbo := Db{
dbo.exec('create table irc_servers (id integer primary key, hostname text, netname text)')
dbo.exec('create table irc_channels (id integer primary key, server_id integer, name text)')
return dbo
}
pub fn (mut self Db) exec(stmt string) {
self.sqlite.exec_one(stmt) or { println('db.sqlite fail $stmt $err') }
type SqlType = int | string
pub struct SqlValue {
name string
value SqlType
}
pub fn (mut self Db) insert(parts []SqlValue) {
mut fields := []string{}
mut values := []string{}
for part in parts {
fields.push(part.name)
values.push(part.value.str())
}
rows, code := self.sqlite.exec("insert into irc_servers ($fields) values ($values)")
println('SQL insert $rows $code')
}