hsdev-0.3.2.0: Haskell development library

Safe HaskellNone
LanguageHaskell98

HsDev.Database.SQLite

Contents

Synopsis

Documentation

initialize :: String -> IO Connection Source #

Initialize database

purge :: SessionMonad m => m () Source #

privateMemory :: String Source #

Private memory for db

sharedMemory :: String Source #

Shared db in memory

query :: (ToRow q, FromRow r, SessionMonad m) => Query -> q -> m [r] Source #

query_ :: (FromRow r, SessionMonad m) => Query -> m [r] Source #

execute :: (ToRow q, SessionMonad m) => Query -> q -> m () Source #

executeMany :: (ToRow q, SessionMonad m) => Query -> [q] -> m () Source #

updateModules :: SessionMonad m => [InspectedModule] -> m () Source #

Update a bunch of modules

Utils

Reexports

newtype Only a #

The 1-tuple type or single-value "collection".

This type is structurally equivalent to the Identity type, but its intent is more about serving as the anonymous 1-tuple type missing from Haskell for attaching typeclass instances.

Parameter usage example:

encodeSomething (Only (42::Int))

Result usage example:

xs <- decodeSomething
forM_ xs $ \(Only id) -> {- ... -}

Constructors

Only 

Fields

Instances
Functor Only 
Instance details

Defined in Data.Tuple.Only

Methods

fmap :: (a -> b) -> Only a -> Only b #

(<$) :: a -> Only b -> Only a #

Eq a => Eq (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

(==) :: Only a -> Only a -> Bool #

(/=) :: Only a -> Only a -> Bool #

Data a => Data (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Only a -> c (Only a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Only a) #

toConstr :: Only a -> Constr #

dataTypeOf :: Only a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Only a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a)) #

gmapT :: (forall b. Data b => b -> b) -> Only a -> Only a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Only a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Only a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Only a -> m (Only a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Only a -> m (Only a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Only a -> m (Only a) #

Ord a => Ord (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

compare :: Only a -> Only a -> Ordering #

(<) :: Only a -> Only a -> Bool #

(<=) :: Only a -> Only a -> Bool #

(>) :: Only a -> Only a -> Bool #

(>=) :: Only a -> Only a -> Bool #

max :: Only a -> Only a -> Only a #

min :: Only a -> Only a -> Only a #

Read a => Read (Only a) 
Instance details

Defined in Data.Tuple.Only

Show a => Show (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

showsPrec :: Int -> Only a -> ShowS #

show :: Only a -> String #

showList :: [Only a] -> ShowS #

Generic (Only a) 
Instance details

Defined in Data.Tuple.Only

Associated Types

type Rep (Only a) :: * -> * #

Methods

from :: Only a -> Rep (Only a) x #

to :: Rep (Only a) x -> Only a #

NFData a => NFData (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

rnf :: Only a -> () #

FromField a => FromRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (Only a) #

ToField a => ToRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: Only a -> [SQLData] #

type Rep (Only a) 
Instance details

Defined in Data.Tuple.Only

type Rep (Only a) = D1 (MetaData "Only" "Data.Tuple.Only" "Only-0.1-ESoRmRbP5ByJm8IsgOJKc0" True) (C1 (MetaCons "Only" PrefixI True) (S1 (MetaSel (Just "fromOnly") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

data SQLData #

Instances
Eq SQLData 
Instance details

Defined in Database.SQLite3

Methods

(==) :: SQLData -> SQLData -> Bool #

(/=) :: SQLData -> SQLData -> Bool #

Show SQLData 
Instance details

Defined in Database.SQLite3

FromField SQLData 
Instance details

Defined in Database.SQLite.Simple.FromField

ToField SQLData 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: SQLData -> SQLData #

data SQLError #

Exception thrown when SQLite3 reports an error.

direct-sqlite may throw other types of exceptions if you misuse the API.

Constructors

SQLError 

Fields

Instances
Eq SQLError 
Instance details

Defined in Database.SQLite3

Show SQLError 
Instance details

Defined in Database.SQLite3

Exception SQLError 
Instance details

Defined in Database.SQLite3

data Error #

Constructors

ErrorOK

Successful result

ErrorError

SQL error or missing database

ErrorInternal

Internal logic error in SQLite

ErrorPermission

Access permission denied

ErrorAbort

Callback routine requested an abort

ErrorBusy

The database file is locked

ErrorLocked

A table in the database is locked

ErrorNoMemory

A malloc() failed

ErrorReadOnly

Attempt to write a readonly database

ErrorInterrupt

Operation terminated by sqlite3_interrupt()

ErrorIO

Some kind of disk I/O error occurred

ErrorCorrupt

The database disk image is malformed

ErrorNotFound

Unknown opcode in sqlite3_file_control()

ErrorFull

Insertion failed because database is full

ErrorCan'tOpen

Unable to open the database file

ErrorProtocol

Database lock protocol error

ErrorEmpty

Database is empty

ErrorSchema

The database schema changed

ErrorTooBig

String or BLOB exceeds size limit

ErrorConstraint

Abort due to constraint violation

ErrorMismatch

Data type mismatch

ErrorMisuse

Library used incorrectly

ErrorNoLargeFileSupport

Uses OS features not supported on host

ErrorAuthorization

Authorization denied

ErrorFormat

Auxiliary database format error

ErrorRange

2nd parameter to sqlite3_bind out of range

ErrorNotADatabase

File opened that is not a database file

ErrorRow

sqlite3_step() has another row ready

ErrorDone

sqlite3_step() has finished executing

Instances
Eq Error 
Instance details

Defined in Database.SQLite3.Bindings.Types

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

Show Error 
Instance details

Defined in Database.SQLite3.Bindings.Types

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

FFIType Error CError 
Instance details

Defined in Database.SQLite3.Bindings.Types

Methods

toFFI :: Error -> CError #

fromFFI :: CError -> Error #

totalChanges :: Connection -> IO Int #

http://www.sqlite.org/c3ref/total_changes.html

Return the total number of row changes caused by INSERT, DELETE, or UPDATE statements since the Database was opened.

changes :: Connection -> IO Int #

http://www.sqlite.org/c3ref/changes.html

Return the number of rows that were changed, inserted, or deleted by the most recent INSERT, DELETE, or UPDATE statement.

lastInsertRowId :: Connection -> IO Int64 #

Returns the rowid of the most recent successful INSERT on the given database connection.

See also http://www.sqlite.org/c3ref/last_insert_rowid.html.

withExclusiveTransaction :: Connection -> IO a -> IO a #

Run an IO action inside a SQL transaction started with BEGIN EXCLUSIVE TRANSACTION, which immediately blocks all other database connections from writing, and other connections from reading (exception: read_uncommitted connections are allowed to read.) If the action throws any kind of an exception, the transaction will be rolled back with ROLLBACK TRANSACTION. Otherwise the results are committed with COMMIT TRANSACTION.

withImmediateTransaction :: Connection -> IO a -> IO a #

Run an IO action inside a SQL transaction started with BEGIN IMMEDIATE TRANSACTION, which immediately blocks all other database connections from writing. The default SQLite3 BEGIN TRANSACTION does not acquire the write lock on BEGIN nor on SELECT but waits until you try to change data. If the action throws any kind of an exception, the transaction will be rolled back with ROLLBACK TRANSACTION. Otherwise the results are committed with COMMIT TRANSACTION.

nextRow :: FromRow r => Statement -> IO (Maybe r) #

Extracts the next row from the prepared statement.

foldNamed :: FromRow row => Connection -> Query -> [NamedParam] -> a -> (a -> row -> IO a) -> IO a #

A version of fold where the query parameters (placeholders) are named.

fold_ :: FromRow row => Connection -> Query -> a -> (a -> row -> IO a) -> IO a #

A version of fold which does not perform parameter substitution.

fold :: (FromRow row, ToRow params) => Connection -> Query -> params -> a -> (a -> row -> IO a) -> IO a #

Perform a SELECT or other SQL query that is expected to return results. Results are converted and fed into the action callback as they are being retrieved from the database.

This allows gives the possibility of processing results in constant space (for instance writing them to disk).

Exceptions that may be thrown:

queryWith_ :: RowParser r -> Connection -> Query -> IO [r] #

A version of query that does not perform query substitution and takes an explicit RowParser.

queryWith :: ToRow q => RowParser r -> Connection -> Query -> q -> IO [r] #

A version of query that takes an explicit RowParser.

withStatement :: Connection -> Query -> (Statement -> IO a) -> IO a #

Opens a prepared statement, executes an action using this statement, and closes the statement, even in the presence of exceptions.

closeStatement :: Statement -> IO () #

Closes a prepared statement.

openStatement :: Connection -> Query -> IO Statement #

Opens a prepared statement. A prepared statement must always be closed with a corresponding call to closeStatement before closing the connection. Use nextRow to iterate on the values returned. Once nextRow returns Nothing, you need to invoke reset before reexecuting the statement again with nextRow.

withBind :: ToRow params => Statement -> params -> IO a -> IO a #

Binds parameters to a prepared statement, and resets the statement when the callback completes, even in the presence of exceptions.

Use withBind to reuse prepared statements. Because it resets the statement after each usage, it avoids a pitfall involving implicit transactions. SQLite creates an implicit transaction if you don't say BEGIN explicitly, and does not commit it until all active statements are finished with either reset or closeStatement.

columnCount :: Statement -> IO ColumnIndex #

Return number of columns in the query

columnName :: Statement -> ColumnIndex -> IO Text #

Return the name of a a particular column in the result set of a Statement. Throws an ArrayException if the colum index is out of bounds.

http://www.sqlite.org/c3ref/column_name.html

reset :: Statement -> IO () #

Resets a statement. This does not reset bound parameters, if any, but allows the statement to be reexecuted again by invoking nextRow.

bindNamed :: Statement -> [NamedParam] -> IO () #

Binds named parameters to a prepared statement.

bind :: ToRow params => Statement -> params -> IO () #

Binds parameters to a prepared statement. Once nextRow returns Nothing, the statement must be reset with the reset function before it can be executed again by calling nextRow.

setTrace :: Connection -> Maybe (Text -> IO ()) -> IO () #

http://www.sqlite.org/c3ref/profile.html

Enable/disable tracing of SQL execution. Tracing can be disabled by setting Nothing as the logger callback.

Warning: If the logger callback throws an exception, your whole program may crash. Enable only for debugging!

withConnection :: String -> (Connection -> IO a) -> IO a #

Opens a database connection, executes an action using this connection, and closes the connection, even in the presence of exceptions.

close :: Connection -> IO () #

Close a database connection.

open :: String -> IO Connection #

Open a database connection to a given file. Will throw an exception if it cannot connect.

Every open must be closed with a call to close.

If you specify ":memory:" or an empty string as the input filename, then a private, temporary in-memory database is created for the connection. This database will vanish when you close the connection.

newtype Statement #

An SQLite prepared statement.

Constructors

Statement 

newtype ColumnIndex #

Index of a column in a result set. Column indices start from 0.

Constructors

ColumnIndex ColumnIndex 
Instances
Enum ColumnIndex 
Instance details

Defined in Database.SQLite.Simple

Eq ColumnIndex 
Instance details

Defined in Database.SQLite.Simple

Integral ColumnIndex 
Instance details

Defined in Database.SQLite.Simple

Num ColumnIndex 
Instance details

Defined in Database.SQLite.Simple

Ord ColumnIndex 
Instance details

Defined in Database.SQLite.Simple

Real ColumnIndex 
Instance details

Defined in Database.SQLite.Simple

data NamedParam where #

Constructors

(:=) :: NamedParam infixr 3 
Instances
Show NamedParam 
Instance details

Defined in Database.SQLite.Simple

data FormatError #

Exception thrown if a Query was malformed. This may occur if the number of '?' characters in the query string does not match the number of parameters provided.

Constructors

FormatError 

class FromRow a where #

A collection type that can be converted from a sequence of fields. Instances are provided for tuples up to 10 elements and lists of any length.

Note that instances can defined outside of sqlite-simple, which is often useful. For example, here's an instance for a user-defined pair:

@data User = User { name :: String, fileQuota :: Int }

instance FromRow User where fromRow = User <$> field <*> field @

The number of calls to field must match the number of fields returned in a single row of the query result. Otherwise, a ConversionFailed exception will be thrown.

Note the caveats associated with user-defined implementations of fromRow.

Minimal complete definition

fromRow

Methods

fromRow :: RowParser a #

Instances
FromRow Symbol # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Sandbox # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Info # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Test # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Executable # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Library # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Project # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow ModulePackage # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow ModuleLocation # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow ModuleId # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow SymbolId # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Position # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Region # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow OutputMessage # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Inspection # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow SymbolUsage # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow SymbolInfo # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Symbol # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow Import # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromRow TypedExpr # 
Instance details

Defined in HsDev.Database.SQLite.Instances

FromField a => FromRow [a] 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser [a] #

FromField a => FromRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (Only a) #

FromRow a => FromRow (Note a) # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

fromRow :: RowParser (Note a) #

FromRow a => FromRow (Scoped a) # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

fromRow :: RowParser (Scoped a) #

(FromField a, FromField b) => FromRow (a, b) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b) #

(FromRow a, FromRow b) => FromRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a :. b) #

(FromField a, FromField b, FromField c) => FromRow (a, b, c) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c) #

(FromField a, FromField b, FromField c, FromField d) => FromRow (a, b, c, d) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d) #

(FromField a, FromField b, FromField c, FromField d, FromField e) => FromRow (a, b, c, d, e) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f) => FromRow (a, b, c, d, e, f) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g) => FromRow (a, b, c, d, e, f, g) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h) => FromRow (a, b, c, d, e, f, g, h) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i) => FromRow (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j) => FromRow (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j) #

data ResultError #

Exception thrown if conversion from a SQL value to a Haskell value fails.

Constructors

Incompatible

The SQL and Haskell types are not compatible.

UnexpectedNull

A SQL NULL was encountered when the Haskell type did not permit it.

ConversionFailed

The SQL value could not be parsed, or could not be represented as a valid Haskell value, or an unexpected low-level error occurred (e.g. mismatch between metadata and actual data in a row).

class ToRow a where #

A collection type that can be turned into a list of SQLData elements.

Minimal complete definition

toRow

Methods

toRow :: a -> [SQLData] #

ToField a collection of values.

Instances
ToRow () 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: () -> [SQLData] #

ToRow Symbol # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Symbol -> [SQLData] #

ToRow Sandbox # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Sandbox -> [SQLData] #

ToRow Project # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Project -> [SQLData] #

ToRow ModulePackage # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: ModulePackage -> [SQLData] #

ToRow ModuleLocation # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: ModuleLocation -> [SQLData] #

ToRow ModuleId # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: ModuleId -> [SQLData] #

ToRow SymbolId # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: SymbolId -> [SQLData] #

ToRow Position # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Position -> [SQLData] #

ToRow Region # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Region -> [SQLData] #

ToRow OutputMessage # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: OutputMessage -> [SQLData] #

ToRow Inspection # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Inspection -> [SQLData] #

ToRow SymbolInfo # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: SymbolInfo -> [SQLData] #

ToRow Symbol # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Symbol -> [SQLData] #

ToRow Import # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Import -> [SQLData] #

ToRow TypedExpr # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: TypedExpr -> [SQLData] #

ToField a => ToRow [a] 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: [a] -> [SQLData] #

ToField a => ToRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: Only a -> [SQLData] #

ToRow a => ToRow (Note a) # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Note a -> [SQLData] #

ToRow a => ToRow (Scoped a) # 
Instance details

Defined in HsDev.Database.SQLite.Instances

Methods

toRow :: Scoped a -> [SQLData] #

(ToField a, ToField b) => ToRow (a, b) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b) -> [SQLData] #

(ToRow a, ToRow b) => ToRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a :. b) -> [SQLData] #

(ToField a, ToField b, ToField c) => ToRow (a, b, c) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d) => ToRow (a, b, c, d) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e) => ToRow (a, b, c, d, e) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f) => ToRow (a, b, c, d, e, f) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g) => ToRow (a, b, c, d, e, f, g) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h) => ToRow (a, b, c, d, e, f, g, h) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g, h) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h, ToField i) => ToRow (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g, h, i) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h, ToField i, ToField j) => ToRow (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g, h, i, j) -> [SQLData] #

newtype Query #

A query string. This type is intended to make it difficult to construct a SQL query by concatenating string fragments, as that is an extremely common way to accidentally introduce SQL injection vulnerabilities into an application.

This type is an instance of IsString, 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.SQLite.Simple

q :: Query
q = "select ?"

The underlying type is a Text, and literal Haskell strings that contain Unicode characters will be correctly transformed to UTF-8.

Constructors

Query 

Fields

Instances
Eq Query 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

(==) :: Query -> Query -> Bool #

(/=) :: Query -> Query -> Bool #

Ord Query 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

compare :: Query -> Query -> Ordering #

(<) :: Query -> Query -> Bool #

(<=) :: Query -> Query -> Bool #

(>) :: Query -> Query -> Bool #

(>=) :: Query -> Query -> Bool #

max :: Query -> Query -> Query #

min :: Query -> Query -> Query #

Read Query 
Instance details

Defined in Database.SQLite.Simple.Types

Show Query 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

showsPrec :: Int -> Query -> ShowS #

show :: Query -> String #

showList :: [Query] -> ShowS #

IsString Query 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

fromString :: String -> Query #

Semigroup Query 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

(<>) :: Query -> Query -> Query #

sconcat :: NonEmpty Query -> Query #

stimes :: Integral b => b -> Query -> Query #

Monoid Query 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

mempty :: Query #

mappend :: Query -> Query -> Query #

mconcat :: [Query] -> Query #

data h :. t infixr 3 #

A composite type to parse your custom data structures without having to define dummy newtype wrappers every time.

instance FromRow MyData where ...
instance FromRow MyData2 where ...

then I can do the following for free:

res <- query' c "..."
forM res $ \(MyData{..} :. MyData2{..}) -> do
  ....

Constructors

h :. t infixr 3 
Instances
(Eq h, Eq t) => Eq (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

(==) :: (h :. t) -> (h :. t) -> Bool #

(/=) :: (h :. t) -> (h :. t) -> Bool #

(Ord h, Ord t) => Ord (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

compare :: (h :. t) -> (h :. t) -> Ordering #

(<) :: (h :. t) -> (h :. t) -> Bool #

(<=) :: (h :. t) -> (h :. t) -> Bool #

(>) :: (h :. t) -> (h :. t) -> Bool #

(>=) :: (h :. t) -> (h :. t) -> Bool #

max :: (h :. t) -> (h :. t) -> h :. t #

min :: (h :. t) -> (h :. t) -> h :. t #

(Read h, Read t) => Read (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

readsPrec :: Int -> ReadS (h :. t) #

readList :: ReadS [h :. t] #

readPrec :: ReadPrec (h :. t) #

readListPrec :: ReadPrec [h :. t] #

(Show h, Show t) => Show (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

showsPrec :: Int -> (h :. t) -> ShowS #

show :: (h :. t) -> String #

showList :: [h :. t] -> ShowS #

(FromRow a, FromRow b) => FromRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a :. b) #

(ToRow a, ToRow b) => ToRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a :. b) -> [SQLData] #

newtype Connection #

Connection to an open database.

You can use connectionHandle to gain access to the underlying http://hackage.haskell.org/package/direct-sqlite connection. This may be useful if you need to access some direct-sqlite functionality that's not exposed in the sqlite-simple API. This should be a safe thing to do although mixing both APIs is discouraged.

Constructors

Connection