Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: breaking code to several lines (Miro Karpis)
2. Database.SQLite.Simple: Select query with more than 10
elements tuple (Miro Karpis)
3. Re: Database.SQLite.Simple: Select query with more than 10
elements tuple (David McBride)
----------------------------------------------------------------------
Message: 1
Date: Mon, 23 Dec 2013 23:05:13 +0100
From: Miro Karpis <[email protected]>
To: David McBride <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] breaking code to several lines
Message-ID:
<CAJnnbxHn+0-_6KM=bgphay5go560osb39tqwwebo_q8dm8e...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
thank you very much
m.
On Mon, Dec 23, 2013 at 10:57 PM, David McBride <[email protected]> wrote:
> Another option is a string quasiquoter. There are several options
> available, non interpolating ones ones such as string-qq or string-quote,
> as well as ones that allow you to interpolate variables, like
> interpolatedstring-qq.
>
>
> On Mon, Dec 23, 2013 at 4:42 PM, Miro Karpis <[email protected]>wrote:
>
>> Hi please,... I have one sql insert statement which is too long to be on
>> one line. Is there a way that I can break it several lines? Or does it have
>> to be everything in one line?
>>
>> here is the query:
>> execute_ conn "INSERT INTO ttableXY
>> (column1, column2, column3, column4, column5, column6, column7) VALUES
>> ('var1', 'var2', 'var3', 'var4', 'var5', 'var6', 'var7')"
>>
>> Thanks,
>> Miro
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131223/c46eb7c9/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 24 Dec 2013 01:37:45 +0100
From: Miro Karpis <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Database.SQLite.Simple: Select query with
more than 10 elements tuple
Message-ID:
<CAJnnbxGEn=XFw79ri82PSfN-W0GYKSgg=mzfhgq_d9oznmo...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi, please ... I need help with following:
I have a table with 11 columns. I would like to create a query where in
return I should get values of all columns. Problem is that when I try with
10 elements everything works OK. With 11 I will get compile error.
I found in the Database.SQLite.Simple documentation following:
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.
So is it possible to select more than 10 columns in one query? It must be
right?
working code:
-------------------------
queryX :: Query
queryX = "SELECT el1, el2, el3, el4, el5, el6, el7, el8, el9, el10 FROM
tableX"
saveBtceTickerData :: IO ()
saveBtceTickerData = do
conn <- open "../mydb.sqlite"
r <- query_ conn queryX :: IO [(Double, Int, Double, Double, Double,
Double, Double, Double, Double, Double)]
mapM_ print r
close conn
putStrLn "done"
non-working code:
-------------------------
someQuery :: Query
someQuery = "SELECT el1, el2, el3, el4, el5, el6, el7, el8, el9, el10, el11
FROM tableX"
saveBtceTickerData :: IO ()
saveBtceTickerData = do
conn <- open "../mydb.sqlite"
r <- query_ conn queryX :: IO [(Double, Int, Double, Double, Double,
Double, Double, Double, Double, Double, Double)]
mapM_ print r
close conn
putStrLn "done"
------
Error output:
No instance for (FromRow
(Double,
Int,
Double,
Double,
Double,
Double,
Double,
Double,
Double,
Double,
Double))
arising from a use of `query_'
Possible fix:
add an instance declaration for
(FromRow
(Double,
Int,
Double,
Double,
Double,
Double,
Double,
Double,
Double,
Double,
Double))
thanks,
m.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131224/1cfbb898/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 23 Dec 2013 20:16:07 -0500
From: David McBride <[email protected]>
To: [email protected], The Haskell-Beginners Mailing List -
Discussion of primarily beginner-level topics related to Haskell
<[email protected]>
Subject: Re: [Haskell-beginners] Database.SQLite.Simple: Select query
with more than 10 elements tuple
Message-ID:
<can+tr4192lufqom5f0iaaoc1ywn_gkhgsmphi16f7ebjyf7...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
You can use the :. operator to separate different types. You can string
them together for as long as you want. WIth ScopedTypeVariables extension
enabled you can type them in an anon function like so.
forM_ res $ \((Only (x :: Int)) :. (Only (y :: Int)) ) -> do
print (show x) ++ (show y)
You can also create your own 11+ item datatype and create a fromRow
instance for it, which would serve the same purpose.
On Mon, Dec 23, 2013 at 7:37 PM, Miro Karpis <[email protected]>wrote:
> Hi, please ... I need help with following:
>
> I have a table with 11 columns. I would like to create a query where in
> return I should get values of all columns. Problem is that when I try with
> 10 elements everything works OK. With 11 I will get compile error.
>
> I found in the Database.SQLite.Simple documentation following:
> 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.
>
> So is it possible to select more than 10 columns in one query? It must be
> right?
>
>
> working code:
> -------------------------
> queryX :: Query
> queryX = "SELECT el1, el2, el3, el4, el5, el6, el7, el8, el9, el10 FROM
> tableX"
>
> saveBtceTickerData :: IO ()
> saveBtceTickerData = do
> conn <- open "../mydb.sqlite"
> r <- query_ conn queryX :: IO [(Double, Int, Double, Double, Double,
> Double, Double, Double, Double, Double)]
> mapM_ print r
> close conn
> putStrLn "done"
>
>
> non-working code:
> -------------------------
> someQuery :: Query
> someQuery = "SELECT el1, el2, el3, el4, el5, el6, el7, el8, el9, el10,
> el11 FROM tableX"
>
> saveBtceTickerData :: IO ()
> saveBtceTickerData = do
> conn <- open "../mydb.sqlite"
> r <- query_ conn queryX :: IO [(Double, Int, Double, Double, Double,
> Double, Double, Double, Double, Double, Double)]
> mapM_ print r
> close conn
> putStrLn "done"
>
> ------
> Error output:
>
> No instance for (FromRow
>
> (Double,
>
> Int,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double))
>
> arising from a use of `query_'
>
> Possible fix:
>
> add an instance declaration for
>
> (FromRow
>
> (Double,
>
> Int,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double,
>
> Double))
>
>
> thanks,
> m.
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131223/8ad133bb/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 66, Issue 18
*****************************************