!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  experimental&Leon P Smith <leon@melding-monads.com>2 is a quasiquoter that eases the syntactic burden D of writing big sql statements in Haskell source code. It attempts F to minimize whitespace. Note that this implementation is incomplete C and can mess up your syntax; it only really understands standard D sql string literals (default in PostgreSQL 9) and not the extended ? escape syntax or other situations where white space should be  preserved as is. portable experimental&Leon P Smith <leon@melding-monads.com> :Wrap a mostly-binary string to be escaped in hexadecimal. $Wrap a list of values for use in an IN clause. Replaces a  single "?"1 character with a parenthesized list of rendered  values.  Example: = query c "select * from whatever where id in ?" (In [3,4,5]) A single-value " collection". AThis is useful if you need to supply a single parameter to a SQL 6 query, or extract a single column from a SQL result. Parameter example:  query c " select x from scores where x > ?" (  (42::Int))Result example: xs < - query_ c "select id from users"  forM_ xs $ \(  id) -> {- ... -} >A query string. This type is intended to make it difficult to E construct a SQL query by concatenating string fragments, as that is A an extremely common way to accidentally introduce SQL injection & vulnerabilities into an application. This type is an instance of , so the easiest way to $ construct a query is to enable the OverloadedStrings language = extension and then simply write the query in double quotes.  $ {-# LANGUAGE OverloadedStrings #-}  # import Database.PostgreSQL.Simple   q :: Query  q = "select ?" The underlying type is a , and literal Haskell strings B that contain Unicode characters will be correctly transformed to  UTF-8. A placeholder for the SQL NULL value.        portable experimental&Leon P Smith <leon@melding-monads.com>>A type that may be used as a single parameter to a SQL query. 6Prepare a value for substitution into a query string. <How to render an element when substituting it into a query. +Concatenate a series of rendering actions. >Escape and enclose in quotes before substituting. Use for all < text-like types, and anything else that may contain unsafe  characters when rendered. ;Render without escaping or quoting. Use for non-text types  such as numbers, when you are certain that they will not A introduce formatting vulnerabilities via use of characters such  as spaces or "'". 0Surround a string with single-quote characters: "'" This function does not perform any other escaping. portable experimental&Leon P Smith <leon@melding-monads.com>>A collection type that can be turned into a list of rendering  s. Instances should use the  method of the  class : to perform conversion of each element of the collection. Render a collection of values.  experimental&Leon P Smith <leon@melding-monads.com>_ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKL2 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKL2HGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"! IJKL2-HGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKL)MNOPQRSTUVWXYZ[\]^_`abcd5A Field represents metadata about a particular field You don':t particularly want to retain these structures for a long D period of time, as they will retain the entire query result, not  just the field metadata efghijklmnoBConnect with the given username to the given database. Will throw & an exception if it cannot connect. pqrstHAtomically perform an action with the database handle, if there is one. u*MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu)defghijklm`abc]_^XYZ[\QRSTUVWnopqrstuMNOP)MNOPNOPQRSTUVWRSTUVWXYZ[\YZ[\]_^^_`abcabcdefghefghijklmnopqrstuMNOPdhijklmdhhijklmMNOPportable experimental&Leon P Smith <leon@melding-monads.com>v.A type that may be converted from a SQL type. w(Convert a SQL value to a Haskell value. >Returns an exception if the conversion fails. In the case of , library instances, this will usually be a x , but may  be a UnicodeException. x=Exception thrown if conversion from a SQL value to a Haskell  value fails. y0The SQL value could not be parsed, or could not 0 be represented as a valid Haskell value, or an 4 unexpected low-level error occurred (e.g. mismatch - between metadata and actual data in a row). zA SQL NULL" was encountered when the Haskell  type did not permit it. {.The SQL and Haskell types are not compatible. |}~ vwxyz{|}~vwx{zy|}~|}~|}~ vwwx {zy|}~|}~|}~yz{|}~ portable experimental&Leon P Smith <leon@melding-monads.com>@A collection type that can be converted from a list of strings. Instances should use the w method of the v class : to perform conversion of each element of the collection. CThis example instance demonstrates how to convert a two-column row C into a Haskell pair. Each field in the metadata is paired up with 4 each value from the row, and the two are passed to w.    instance (v a, v b) =>  (a,b) where   [fa,fb] [va,vb] = (a,b)  where !a = w fa va  !b = w fb vb   fs vs =  fs vs 2 @Notice that this instance evaluates each element to WHNF before B constructing the pair. By doing this, we guarantee two important  properties: B Keep resource usage under control by preventing the construction % of potentially long-lived thunks.  Ensure that any x that might arise is thrown A immediately, rather than some place later in application code  that cannot handle it. BYou can also declare Haskell types of your own to be instances of  .  6data User { firstName :: String, lastName :: String }   instance  User where   [fa,fb] [va,vb] = User a b  where !a = w fa va  !b = w fb vb   fs vs =  fs vs 5Convert values from a row into a Haskell collection. This function will throw a x if conversion of the  collection fails. Throw a y" exception, indicating a mismatch & between the number of columns in the ed and row, and the . number in the collection to be converted to. 'Descriptors of fields to be converted. %Contents of the row to be converted. 0Number of columns expected for conversion. For 5 instance, if converting to a 3-tuple, the number to  provide here would be 3.  leon@melding-monads.com  experimentalleon@melding-monads.com portable experimental&Leon P Smith <leon@melding-monads.com>Exception thrown if  is used to perform an INSERT-like  operation, or  is used to perform a SELECT-like operation. Exception thrown if a  # could not be formatted correctly. ! This may occur if the number of '?' characters in the query : string does not match the number of parameters provided. Format a query string. DThis function is exposed to help with debugging and logging. Do not * use it to prepare queries for execution. DString parameters are escaped according to the character set in use  on the a`. Throws , if the query string could not be formatted  correctly. 6Format a query string with a variable number of rows. DThis function is exposed to help with debugging and logging. Do not * use it to prepare queries for execution. >The query string must contain exactly one substitution group,  identified by the SQL keyword "VALUES" (case insensitive)  followed by an "("$ character, a series of one or more "?" ' characters separated by commas, and a ")" character. White - space in a substitution group is permitted. Throws , if the query string could not be formatted  correctly.  Execute an INSERT, UPDATE!, or other SQL query that is not  expected to return results. %Returns the number of rows affected. Throws 0 if the query could not be formatted correctly.  A version of + that does not perform query substitution. Execute a multi-row INSERT, UPDATE!, or other SQL query that is not  expected to return results. %Returns the number of rows affected. Throws 0 if the query could not be formatted correctly.  Perform a SELECT/ or other SQL query that is expected to return > results. All results are retrieved and converted before this  function returns. CWhen processing large results, this function will consume a lot of % client-side memory. Consider using fold instead. Exceptions that may be thrown:  5: the query string could not be formatted correctly.  5: the result contains no columns (i.e. you should be  using  instead of ).  x: result conversion failed.  A version of + that does not perform query substitution. ,Execute an action inside a SQL transaction. -This function initiates a transaction with a "begin  transaction"3 statement, then executes the supplied action. If = the action succeeds, the transaction will be completed with   Base.commit before this function returns. If the action throws any kind of exception (not just a J PostgreSQL-related exception), the transaction will be rolled back using  ', then the exception will be rethrown. Rollback a transaction. > rollback :: (MonadCatchIO m,MonadIO m) => Connection -> m () Commit a transaction. < commit :: (MonadCatchIO m,MonadIO m) => Connection -> m () Begin a transaction. ; begin :: (MonadCatchIO m,MonadIO m) => Connection -> m () + QRSTUVW`nopqux|}~1QRSTUVW`   x|}~|}~|}~opqnu      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSSTUVVWXYZ[\\]^_`abccdeffghijklmnopqrstuvwxyz{|}~      j   postgresql-simple-0.0 Database.PostgreSQL.Simple.Field Database.PostgreSQL.Simple.Types Database.PostgreSQL.Simple.SqlQQ Database.PostgreSQL.Simple.Param&Database.PostgreSQL.Simple.QueryParams'Database.PostgreSQL.Simple.BuiltinTypes#Database.PostgreSQL.Simple.Internal!Database.PostgreSQL.Simple.Result'Database.PostgreSQL.Simple.QueryResults'Database.PostgreSQL.Simple.LargeObjects'Database.PostgreSQL.Simple.NotificationDatabase.PostgreSQL.Simplepostgresql-libpq-0.6.1Database.PostgreSQL.LibPQTextBinaryFormatOidsqlInOnlyfromOnlyQuery fromQueryNullParamrenderActionManyEscapePlaininQuotes QueryParams renderParams BuiltinTypeVoidRecord RefcursorNumericVarbitBitTimeWithTimeZoneIntervalTimestampWithTimeZone TimestampTimeDateVarcharBpcharInetMacaddrMoneyCircleUnknown TintervalReltimeAbstimeFloat8Float4CidrLinePolygonBoxPathLsegPointXmlCidXidTidRegprocInt4Int2Int8NameCharByteaBool builtin2oid oid2builtinbuiltin2typname oid2typname RawResultrawFieldrawData ConnectInfo connectHost connectPort connectUserconnectPasswordconnectDatabaseSqlErrorsqlStatesqlNativeError sqlErrorMsgSqlTypeOtherBuiltin ConnectionconnectionHandleconnectionObjectsFieldresultcolumntypenamenametableOid tableColumnformattypeOiddefaultConnectInfoconnectconnectPostgreSQLpostgreSQLConnectionStringoid2intexecwithConnectioncloseResultconvert ResultErrorConversionFailedUnexpectedNull Incompatible errSQLTypeerrHaskellType errMessage QueryResultsconvertResults convertErrorloImportloExport NotificationnotificationPidnotificationChannelnotificationDatagetNotification QueryError qeMessageqeQuery FormatError fmtMessagefmtQuery fmtParams formatQuery formatManyexecuteexecute_ executeManyqueryquery_withTransactionrollbackcommitbeginsqlExpbase Data.StringIsStringbytestring-0.9.2.0Data.ByteString.Internal ByteString renderNullboolbyteacharint8int2int4regproctextoidtidxidcidxmlpointlsegpathboxpolygonlinecidrfloat4float8abstimereltime tintervalunknowncirclemoneymacaddrinetbpcharvarchardatetime timestamp timestamptzintervaltimetzbitvarbitnumeric refcursorrecordvoiddisconnectedErrorCompatleft unescapeBytea mkCompatsmkCompatcompatokTextokText'ok16ok32ok64 doConvert returnErrorattoellipsislockConn unlockConn buildQuery finishExecuteforM' finishQueryfmtError getTypename