diff --git a/includes/database/database.inc b/includes/database/database.inc
index 6e40b27..b5f982b 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -300,6 +300,12 @@ abstract class DatabaseConnection extends PDO {
     // Because the other methods don't seem to work right.
     $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
 
+    // If any driver options have been specified in the connection options,
+    // they take precedence over any options we have set beforehand.
+    if (!empty($this->connectionOptions['driver options'])) {
+      $driver_options = $this->connectionOptions['driver options'] + $driver_options;
+    }
+
     // Call PDO::__construct and PDO::setAttribute.
     parent::__construct($dsn, $username, $password, $driver_options);
 
@@ -307,6 +313,14 @@ abstract class DatabaseConnection extends PDO {
     if (!empty($this->statementClass)) {
       $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
     }
+
+    // If any pdo attributes have been specified in the connection options,
+    // enforce them now.
+    if (!empty($this->connectionOptions['pdo attributes'])) {
+      foreach ($this->connectionOptions['pdo attributes'] as $attribute => $value) {
+        $this->setAttribute($attribute, $value);
+      }
+    }
   }
 
   /**
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index d8ab0e6..b9ec7dd 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -79,6 +79,19 @@
  * varies by driver.  For MySQL, the default is FALSE since MyISAM tables
  * do not support transactions.
  *
+ * Drupal database layer is based on PDO. You can pass any arbitrary driver
+ * option that is supported by the database engine by passing them to the
+ * 'driver options' array. The keys of this array are driver names, values
+ * are the corresponding values. You can also set arbitrary PDO attributes
+ * that will be enforced when the connection to the database is established
+ * using the 'pdo attributes' array with the same format:
+ * @code
+ * 'pdo attributes' => array(
+ *   // Set the timeout to 1 second, instead of the default 30 seconds.
+ *   PDO::ATTR_TIMEOUT => 1,
+ * )
+ * @endcode
+ *
  * For each database, you may optionally specify multiple "target" databases.
  * A target database allows Drupal to try to send certain queries to a
  * different database if it can but fall back to the default connection if not.
