Working with RSQLite to create a SQLite database I want to send several statements at a time - is this possible?
Why this does not work:
sql <- readLines("createtables.sql") dbSendQuery(con,sql)
... and ...
sql <- paste(readLines("createtables.sql"),collapse="") dbSendQuery(con,sql)
... and ...
sql <- paste(readLines("createtables.sql"),collapse="\n") dbSendQuery(con,sql)
while they do:
sql <- "CREATE TABLE birthdays ( nameid INTEGER PRIMARY KEY AUTOINCREMENT , firstname VARCHAR(100) NOT NULL , lastname VARCHAR(100) NOT NULL , birthday DATE ) ; " dbSendQuery(con,sql) sql <- "/* table def: foodtypes */ CREATE TABLE foodtypes ( foodid INTEGER PRIMARY KEY AUTOINCREMENT , foodname VARCHAR(100) NOT NULL, healthy INTEGER, `kcal/100g` float );" dbSendQuery(con,sql)
createtables.sql contents:
CREATE TABLE birthdays ( nameid INTEGER PRIMARY KEY AUTOINCREMENT , firstname VARCHAR(100) NOT NULL , lastname VARCHAR(100) NOT NULL , birthday DATE ) ; CREATE TABLE foodtypes ( foodid INTEGER PRIMARY KEY AUTOINCREMENT , foodname VARCHAR(100) NOT NULL, healthy INTEGER, `kcal/100g` float );
source share