[Haskell-cafe] generics and sql

nadine.and.henry at pobox.com nadine.and.henry at pobox.com
Sun Apr 24 18:11:20 CEST 2011


>>>>> "EZY" == Edward Z Yang <ezyang at MIT.EDU> writes:

    EZY> Where did 'query' come from?  Edward

I left that out because it was just a prebuilt db query.  It came from
something like:

dataNames :: Data a => a -> [String]          
dataNames = constrFields . toConstr

loanNames = datanames (loan :: Loan) 
{- yielding:
["loan_address","loan_initialAmount","loan_interestRate","loan_term","loan_originated","loan_minimumPayment","loan_usualPayment","loan_familiarName","loan_password","loan_lastVisit","loan_nextToLastVisit","loan_emailAddress"] -}



let query = "INSERT INTO loans (" ++ loanNames ++ ") values (" ++ 
               (intercalate ", " (replicate (length loanNames) "?")) ++
               ")"


Best wishes,
H



More information about the Haskell-Cafe mailing list