sqlite3 - How to use a variable in a create table statment -


i use sqllite tcl. in order create table use:

db eval { create table tablename (component text not null, lc int not null) } 

now thats nice if want use variable $tablename instead of fixed table name have use:

db eval "create table $tablename (component text not null, lc int not null)" 

but have read somewhere on stackoveflow 1 should use curly brackets db eval statement ( think security reasons). so, use of "" ok or should somehow different?

the name of table in sqlite expression not support being parameter; parameters can used values. have put table name in using normal tcl variable substitution, , should very careful not let users specify name (have table hold mapping names specified users table names; you've got database, might use it).

try avoid mixing data definition statements or data query statements in table creation, , aware can use :var instead of $var name of parameters substitute; can make things easier when have things dynamically-named table:

db eval "select component $tablename lc = :lc" {     puts "component = $component" } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -