[Feedbac from Mike John Goerzen **20071204063602] { hunk ./en/ch21-databases.xml 7 - Many different applications have the need to store data in databases. hunk ./en/ch21-databases.xml 56 + + Another database abstraction library for Haskell is HSQL, + which shares a similar purpose with HDBC. There is also a + higher-level framework called HaskellDB, which sits atop + either HDBC or HSQL, and is designed to help insulate the + programmer from the details of working with SQL. However, it + does not have as broad appeal because its design limits it to + certain -- albeit quite common -- database access patterns. + + hunk ./en/ch21-databases.xml 89 + + If you want to use HDBC with other databases, check out the + HDBC Known Drivers page at . + There you will find a link to the ODBC binding, which lets you + connect to virtually any database on virtually any platform + (Windows, POSIX, and others). You will also find a PostgreSQL + binding. MySQL is supported via the ODBC binding, and + specific information for MySQL users can be found in the + HDBC-ODBC + API documentation. + hunk ./en/ch21-databases.xml 166 + + Note that a rollback operation only rolls back the changes + since the last &commit;, &rollback;, or &withTransaction;. A + database does not maintain an extensive history like a + version-control system, and there are not multiple levels of + undo in a database. + hunk ./en/ch21-databases.xml 187 + + You will see examples of &commit; later in this chapter, and + examples of &withTransaction; in FIXME: insert ref to + ch22. + hunk ./en/ch21-databases.xml 486 + Here's an example of lazy reading: + + &query.ghci:far; + + Note that you could have used + fetchAllRowsAL' here as well. However, + if you had a large data set to read, it would have consumed + a lot of memory. By reading the data lazily, we can print + out extremely large result sets. hunk ./en/ch21-databases.xml 585 - - - - Threading - - Different database systems have different capabilities - regarding multithreading. The HDBC API spec suggests that, to - be safe, you should not try to issue more than one - simultaneous query over a single connection. Though you may - use a single connection serially across multiple threads. - hunk ./examples/ch21/query.ghci 36 + +--# far +conn <- connectSqlite3 "test1.db" +stmt <- prepare conn "SELECT * from test where id < 2" +execute stmt [] +results <- fetchAllRowsAL stmt +mapM_ print results +disconnect conn hunk ./meta/assignments.txt 25 -JG 21. Talking to databases: Data.Typeable +JG 21. Talking to databases (DONE) hunk ./meta/assignments.txt 38 - +JG APP C. Data.Typeable }