How to build a query string with mysql-simpl?

时间:2016-04-04 17:55:00

标签: haskell

I know that the Query type exists to make code injection difficult. But I need to call "describe tablename" and substitute the table name with the table I want to describe.

Since I'm fairly new to Haskell I have no idea how to accomplish this.

So far the code looks like this:

describe :: String -> SqlQuery [FieldInfo]
describe table = sqlQuery_ "describe " ++ table

But that results in

Couldn't match expected type ‘[Char]’

1 个答案:

答案 0 :(得分:1)

使用fromString将字符串转换为查询

 SqlQuery_ . fromString $ "describe" ++ table

(未经测试,我正在通过手机接听)