common lisp - How to insert multiple records at once using the clsql provided FDML -
is there way of using given fdml interface insert multiple records @ once?
the given insert-record statement can handle 1 value tuple @ once , idea of calling function uncountable times, instead of once bugging me quite bit, , guess (without having done profiling) not fastest approach either.
how this?
; slime 2013-04-02 cl-user> (ql:quickload "clsql") load "clsql": load 1 asdf system: uffi install 1 quicklisp release: clsql ; fetching #<url "http://beta.quicklisp.org/archive/clsql/2013-04-20/clsql-20130420-git.tgz"> ; 900.99kb ================================================== 922,610 bytes in 1.92 seconds (468.78kb/sec) ; loading "clsql" [package uffi].................................... [package cmucl-compat]............................ [package clsql-sys]............................... [package clsql]................................... [package clsql-user].............................. .................................................. [package ansi-loop].............................. ("clsql") cl-user> (ql:quickload "clsql-sqlite3") load "clsql-sqlite3": load 1 asdf system: clsql-sqlite3 ; loading "clsql-sqlite3" [package clsql-uffi].............................. [package clsql-sqlite3]........................... [package sqlite3]........ ("clsql-sqlite3") cl-user> (clsql:connect '("./test.db") :database-type :sqlite3) #<clsql-sqlite3:sqlite3-database ./test.db open {10080c08e3}> cl-user> (clsql:enable-sql-reader-syntax) ; no value cl-user> (clsql:create-table [test_insert] '(([id] integer) ([first_name] text) ([last_name] text))) ; no value cl-user> (clsql:insert-records :into [test_insert] :attributes '(id first_name last_name) :values '(0 "john" "neumann")) ; no value cl-user> (clsql:select [id] [first_name] [last_name] :from [test_insert]) ((0 "john" "neumann")) ("id" "first_name" "last_name") cl-user> (clsql:insert-records :into [test_insert] :attributes '(id first_name last_name) :query (clsql:sql-expression :string "select 1 id, 'albert' first_name, 'einstein' last_name union select 2, 'alan', 'turing'")) ; no value cl-user> (clsql:select [id] [first_name] [last_name] :from [test_insert]) ((0 "john" "neumann") (1 "albert" "einstein") (2 "alan" "turing")) ("id" "first_name" "last_name")
maybe construct insertion query in other way (other databases may provide different syntax). clsql
has (or, more has not) syntax column renaming... you'd have manipulate strings / extend have use symbols instead.
Comments
Post a Comment