postgresql - haskell-postgres --> connect parameter is not a Query -
my program:
import database.postgresql.simple main :: io () main = conn <- connect defaultconnectinfo { connectuser = "postgres" , connectpassword = "password" , connectdatabase = "postgres" } execute conn "create table users (id int, fname varchar(80), lname varchar(80))" () close conn
error:
couldn't match expected type ‘query’ actual type ‘[char]’ in second argument of ‘execute’, namely ‘"create table users (id int, fname varchar(80), lname varchar(80))"’
does user need make above psql string query typed object , send parameter connect
function? tutorial not written way error meaning otherwise.
from the docs:
to construct query, enable ghc's overloadedstrings language extension , write query normal literal string.
overloadedstrings
let write appears string
, have ghc auto-coerce appropriate type (bytestring
, text
, query
). it's useful extension keep in toolbox.
Comments
Post a Comment