[Reindent ch21 John Goerzen **20071106060308] { hunk ./en/ch21-databases.xml 3 - - Using Databases + + Using Databases hunk ./en/ch21-databases.xml 6 - - Many different applications have the need to store data in databases. - Everything from web forums to podcatchers or even backup programs - frequently use databases for persistent storage. SQL-based databases are - often quite convenient: they are fast, can scale from tiny to massive - sizes, can operate over the network, often help handle locking and - transactions, and can even provide failover and redundancy improvements - for applications. Databases come in many different shapes: the large - commercial databases such as Oracle, Open Source engines such as - PostgreSQL or MySQL, and even embeddable engines such as Sqlite. - - - Because databases are so important, Haskell support for them is important - as well. In this chapter, we will introduce you to one of the Haskell - frameworks for working with databases. We will also use this framework - to begin building a podcast downloader, which we will further develop in - FIXME: insert link to ch22. - - - - Overview of HDBC - - At the bottom of the database stack is the database engine. The - database engine is responsible for actually storing data on disk. - Well-known database engines include PostgreSQL, MySQL, and Oracle. - - - Most modern database engines support SQL, the Structured Query - Language, as a standard way of getting data into and out of relational - databases. This book will not provide a tutorial on SQL or relational - database management; for background on that, please refer to - FIXME: add reference to an appropriate O'Reilly title. - hunk ./en/ch21-databases.xml 7 - Once you have a database engine that supports SQL, you need a way to - communicate with it. Each database has its own protocol. Since SQL is - reasonably constant across databases, it is possible to make a generic - interface that uses drivers for each individual protocol. + Many different applications have the need to store data in databases. + Everything from web forums to podcatchers or even backup programs + frequently use databases for persistent storage. SQL-based databases are + often quite convenient: they are fast, can scale from tiny to massive + sizes, can operate over the network, often help handle locking and + transactions, and can even provide failover and redundancy improvements + for applications. Databases come in many different shapes: the large + commercial databases such as Oracle, Open Source engines such as + PostgreSQL or MySQL, and even embeddable engines such as Sqlite. hunk ./en/ch21-databases.xml 18 - Haskell has several different database frameworks available, some - providing high-level layers atop others. For this chapter, we will - concentrate on HDBC, the Haskell DataBase Connectivity system. HDBC is - a database abstraction library. That is, you can write code that uses - HDBC and can access data stored in almost any SQL database with little - or no modification.This assumes you restrict yourself to - using standard SQL. Even if you may never need - to switch underlying database engines, the HDBC system of drivers makes - a large number of choices available to you with a single constant - interface. + Because databases are so important, Haskell support for them is important + as well. In this chapter, we will introduce you to one of the Haskell + frameworks for working with databases. We will also use this framework + to begin building a podcast downloader, which we will further develop in + FIXME: insert link to ch22. hunk ./en/ch21-databases.xml 24 - hunk ./en/ch21-databases.xml 25 - - Installing HDBC and Drivers - - To connect to a given database with HDBC, you need at two packages: - the generic interface, and a driver for your specific database. You - can obtain the generic HDBC package from . FIXME: insert - link to section on installing software. For this chapter, - we will use HDBC version 1.1.3 for examples. - - - You'll also need a database backend and backend driver. For - this chapter, we'll use Sqlite version 3. Sqlite is an embedded - database, so it doesn't require a separate server and is easy to - set up. Many operating systems already ship with Sqlite verison - 3. If yours doesn't, you can download it from . The HDBC homepage has a link to - known HDBC backend drivers. The specific driver for Sqlite - version 3 can be obtained from . - - + + Overview of HDBC + + At the bottom of the database stack is the database engine. The + database engine is responsible for actually storing data on disk. + Well-known database engines include PostgreSQL, MySQL, and Oracle. + + + Most modern database engines support SQL, the Structured Query + Language, as a standard way of getting data into and out of relational + databases. This book will not provide a tutorial on SQL or relational + database management; for background on that, please refer to + FIXME: add reference to an appropriate O'Reilly title. + + + Once you have a database engine that supports SQL, you need a way to + communicate with it. Each database has its own protocol. Since SQL is + reasonably constant across databases, it is possible to make a generic + interface that uses drivers for each individual protocol. + + + Haskell has several different database frameworks available, some + providing high-level layers atop others. For this chapter, we will + concentrate on HDBC, the Haskell DataBase Connectivity system. HDBC is + a database abstraction library. That is, you can write code that uses + HDBC and can access data stored in almost any SQL database with little + or no modification.This assumes you restrict yourself to + using standard SQL. Even if you may never need + to switch underlying database engines, the HDBC system of drivers makes + a large number of choices available to you with a single constant + interface. + + + + + Installing HDBC and Drivers + + To connect to a given database with HDBC, you need at two packages: + the generic interface, and a driver for your specific database. You + can obtain the generic HDBC package from . FIXME: insert + link to section on installing software. For this chapter, + we will use HDBC version 1.1.3 for examples. + + + You'll also need a database backend and backend driver. For + this chapter, we'll use Sqlite version 3. Sqlite is an embedded + database, so it doesn't require a separate server and is easy to + set up. Many operating systems already ship with Sqlite verison + 3. If yours doesn't, you can download it from . The HDBC homepage has a link to + known HDBC backend drivers. The specific driver for Sqlite + version 3 can be obtained from . + + hunk ./en/ch21-databases.xml 82 - - Connecting to Databases - FIXME - + + Connecting to Databases + FIXME + hunk ./en/ch21-databases.xml 87 - - Simple Queries - FIXME - + + Simple Queries + FIXME + hunk ./en/ch21-databases.xml 92 - - Prepared Queries - FIXME - + + Prepared Queries + FIXME + hunk ./en/ch21-databases.xml 97 - - Reading Results - FIXME - + + Reading Results + FIXME + hunk ./en/ch21-databases.xml 102 - - Database Metadata - FIXME - + + Database Metadata + FIXME + hunk ./en/ch21-databases.xml 107 - - Error Handling - FIXME - + + Error Handling + FIXME + hunk ./en/ch21-databases.xml 112 - - Threading - FIXME - + + Threading + FIXME + hunk ./en/ch21-databases.xml 117 - - Data.Typeable - FIXME - - - + + Data.Typeable + FIXME + + + hunk ./en/ch21-databases.xml 124 - + }