Hi,

Having a little trouble with the db library.

In the following test the first '(query db "PRAGMA' works, but the second
fails with the error 'query: multiple statements given
  given: "PRAGMA table_info($1)"'

Any ideas about what I'm doing wrong?

Not including the single quotes in the PRAGMA function (an example from the
sqlite documentation: PRAGMA index_info('idx52');), but while adding to the
first instance succeeds, adding it to the second instance stops the

#lang racket/base
> (require db)
> (define db (sqlite3-connect #:database "test.db" #:mode 'create))
> (query-exec db
>      "CREATE TABLE comments (pid INTEGER, content TEXT)")
> (define dbtables (list-tables db))
> 'cols
> (query db "PRAGMA table_info(comments)")
> (query db "PRAGMA table_info($1)" "comments")


returns

Welcome to DrRacket, version 6.9.0.1--2017-04-08(73d28d8/a) [3m].
> Language: racket/base, with debugging; memory limit: 128 MB.
> 'cols
> (rows-result
>  '(((name . "cid") (decltype . #f))
>    ((name . "name") (decltype . #f))
>    ((name . "type") (decltype . #f))
>    ((name . "notnull") (decltype . #f))
>    ((name . "dflt_value") (decltype . #f))
>    ((name . "pk") (decltype . #f)))
>  '(#(0 "pid" "INTEGER" 0 #<sql-null> 0) #(1 "content" "TEXT" 0 #<sql-null>
> 0)))
> . . query: multiple statements given
>   given: "PRAGMA table_info($1)"


with quotes

> (query db "PRAGMA table_info('$1')" "comments")


stops 'query' from identifying the '$1' argument in the statement

>  query: wrong number of parameters for query
>   expected: 0
>   given: 1


Kind regards,

Stephen

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to