diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,29 @@
+Copyright (c) <2009>, <Maurício C. Antunes>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+    * Neither the name of the author nor the names of contributors
+    may be used to endorse or promote products derived from this
+    software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,6 @@
+#!/usr/bin/env runhaskell
+
+module Main (main) where
+import Distribution.Simple
+
+main = defaultMain
diff --git a/bindings-sqlite3.cabal b/bindings-sqlite3.cabal
new file mode 100644
--- /dev/null
+++ b/bindings-sqlite3.cabal
@@ -0,0 +1,28 @@
+cabal-version: >= 1.2.3
+name: bindings-sqlite3
+homepage: http://bitbucket.org/mauricio/bindings
+synopsis:
+  Check bindings-common package for directions.
+version: 0.0.1
+license: BSD3
+license-file: LICENSE
+maintainer: Maurício C. Antunes
+author: Maurício C. Antunes
+build-type: Simple
+category: FFI
+library
+  hs-source-dirs: src
+  extensions:
+    ForeignFunctionInterface
+    TypeSynonymInstances
+    ScopedTypeVariables
+    EmptyDataDecls
+  build-depends: base, bindings-common
+  exposed-modules:
+    Bindings.Sqlite3
+  pkgconfig-depends:
+    sqlite3 >= 3.6.10
+  other-modules:
+    Sqlite3Constants
+    Sqlite3Functions
+    Sqlite3Types
diff --git a/src/Bindings/Sqlite3.hs b/src/Bindings/Sqlite3.hs
new file mode 100644
--- /dev/null
+++ b/src/Bindings/Sqlite3.hs
@@ -0,0 +1,696 @@
+module Bindings.Sqlite3 (
+
+    -- * Run-Time Library Version Numbers
+    -- <http://sqlite.org/c3ref/libversion.html>
+
+    sqlite3_version,
+    sqlite3_libversion,
+    sqlite3_libversion_number,
+
+    -- * Test To See If The Library Is Threadsafe
+    -- <http://sqlite.org/c3ref/threadsafe.html>
+
+    sqlite3_threadsafe,
+
+    -- * Database Connection Handle
+    -- <http://sqlite.org/c3ref/sqlite3.html>
+
+    Sqlite3,
+
+    -- * Closing A Database Connection
+    -- <http://sqlite.org/c3ref/close.html>
+
+    sqlite3_close,
+
+    -- * One-Step Query Execution Interface
+    -- <http://sqlite.org/c3ref/exec.html>
+
+    sqlite3_exec,
+
+    -- * Result Codes
+    -- <http://sqlite.org/c3ref/c_abort.html>
+
+    _SQLITE_OK,
+    _SQLITE_ERROR,
+    _SQLITE_INTERNAL,
+    _SQLITE_PERM,
+    _SQLITE_ABORT,
+    _SQLITE_BUSY,
+    _SQLITE_LOCKED,
+    _SQLITE_NOMEM,
+    _SQLITE_READONLY,
+    _SQLITE_INTERRUPT,
+    _SQLITE_IOERR,
+    _SQLITE_CORRUPT,
+    _SQLITE_NOTFOUND,
+    _SQLITE_FULL,
+    _SQLITE_CANTOPEN,
+    _SQLITE_PROTOCOL,
+    _SQLITE_EMPTY,
+    _SQLITE_SCHEMA,
+    _SQLITE_TOOBIG,
+    _SQLITE_CONSTRAINT,
+    _SQLITE_MISMATCH,
+    _SQLITE_MISUSE,
+    _SQLITE_NOLFS,
+    _SQLITE_AUTH,
+    _SQLITE_FORMAT,
+    _SQLITE_RANGE,
+    _SQLITE_NOTADB,
+    _SQLITE_ROW,
+    _SQLITE_DONE,
+
+    -- * Extended Result Codes
+    -- <http://sqlite.org/c3ref/c_ioerr_access.html>
+
+    _SQLITE_IOERR_READ,
+    _SQLITE_IOERR_SHORT_READ,
+    _SQLITE_IOERR_WRITE,
+    _SQLITE_IOERR_FSYNC,
+    _SQLITE_IOERR_DIR_FSYNC,
+    _SQLITE_IOERR_TRUNCATE,
+    _SQLITE_IOERR_FSTAT,
+    _SQLITE_IOERR_UNLOCK,
+    _SQLITE_IOERR_RDLOCK,
+    _SQLITE_IOERR_DELETE,
+    _SQLITE_IOERR_BLOCKED,
+    _SQLITE_IOERR_NOMEM,
+    _SQLITE_IOERR_ACCESS,
+    _SQLITE_IOERR_CHECKRESERVEDLOCK,
+    _SQLITE_IOERR_LOCK,
+    _SQLITE_IOERR_CLOSE,
+    _SQLITE_IOERR_DIR_CLOSE,
+
+    -- * Flags For File Open Operations
+    -- <http://sqlite.org/c3ref/c_open_create.html>
+
+    _SQLITE_OPEN_READONLY,
+    _SQLITE_OPEN_READWRITE,
+    _SQLITE_OPEN_CREATE,
+    _SQLITE_OPEN_DELETEONCLOSE,
+    _SQLITE_OPEN_EXCLUSIVE,
+    _SQLITE_OPEN_MAIN_DB,
+    _SQLITE_OPEN_TEMP_DB,
+    _SQLITE_OPEN_TRANSIENT_DB,
+    _SQLITE_OPEN_MAIN_JOURNAL,
+    _SQLITE_OPEN_TEMP_JOURNAL,
+    _SQLITE_OPEN_SUBJOURNAL,
+    _SQLITE_OPEN_MASTER_JOURNAL,
+    _SQLITE_OPEN_NOMUTEX,
+    _SQLITE_OPEN_FULLMUTEX,
+
+    -- * Device Characteristics
+    -- <http://sqlite.org/c3ref/c_iocap_atomic.html>
+
+    _SQLITE_IOCAP_ATOMIC,
+    _SQLITE_IOCAP_ATOMIC512,
+    _SQLITE_IOCAP_ATOMIC1K,
+    _SQLITE_IOCAP_ATOMIC2K,
+    _SQLITE_IOCAP_ATOMIC4K,
+    _SQLITE_IOCAP_ATOMIC8K,
+    _SQLITE_IOCAP_ATOMIC16K,
+    _SQLITE_IOCAP_ATOMIC32K,
+    _SQLITE_IOCAP_ATOMIC64K,
+    _SQLITE_IOCAP_SAFE_APPEND,
+    _SQLITE_IOCAP_SEQUENTIAL,
+
+    -- * File Locking Levels
+    -- <http://sqlite.org/c3ref/c_lock_exclusive.html>
+
+    _SQLITE_LOCK_NONE,
+    _SQLITE_LOCK_SHARED,
+    _SQLITE_LOCK_RESERVED,
+    _SQLITE_LOCK_PENDING,
+    _SQLITE_LOCK_EXCLUSIVE,
+
+    -- * Synchronization Type Flags
+    -- <http://sqlite.org/c3ref/c_sync_dataonly.html>
+
+    _SQLITE_SYNC_NORMAL,
+    _SQLITE_SYNC_FULL,
+    _SQLITE_SYNC_DATAONLY,
+
+    -- * OS Interface Open File Handle
+    -- <http://sqlite.org/c3ref/file.html>
+
+    Sqlite3_file,
+
+    -- * OS Interface File Virtual Methods Object
+    -- <http://sqlite.org/c3ref/io_methods.html>
+
+    Sqlite3_io_methods,
+
+    -- * Standard File Control Opcodes
+    -- <http://sqlite.org/c3ref/c_fcntl_lockstate.html>
+
+    _SQLITE_FCNTL_LOCKSTATE,
+    _SQLITE_GET_LOCKPROXYFILE,
+    _SQLITE_SET_LOCKPROXYFILE,
+    _SQLITE_LAST_ERRNO,
+
+    -- * Mutex Handle
+    -- <http://sqlite.org/c3ref/mutex.html>
+
+    Sqlite3_mutex,
+
+    -- * OS Interface Object
+    -- <http://sqlite.org/c3ref/vfs.html>
+
+    Sqlite3_vfs,
+
+    -- * Flags for the xAccess VFS method
+    -- <http://sqlite.org/c3ref/c_access_exists.html>
+
+    _SQLITE_ACCESS_EXISTS,
+    _SQLITE_ACCESS_READWRITE,
+    _SQLITE_ACCESS_READ,
+
+    -- * Initialize The SQLite Library
+    -- <http://sqlite.org/c3ref/initialize.html>
+
+    sqlite3_initialize,
+    sqlite3_shutdown,
+    sqlite3_os_init,
+    sqlite3_os_end,
+
+    -- * Enable Or Disable Extended Result Codes
+    -- <http://sqlite.org/c3ref/extended_result_codes.html>
+
+    sqlite3_extended_result_codes,
+
+    -- * Last Insert Rowid
+    -- <http://sqlite.org/c3ref/last_insert_rowid.html>
+
+    sqlite3_last_insert_rowid,
+
+    -- * Count The Number Of Rows Modified
+    -- <http://sqlite.org/c3ref/changes.html>
+
+    sqlite3_changes,
+
+    -- * Total Number Of Rows Modified
+    -- <http://sqlite.org/c3ref/total_changes.html>
+
+    sqlite3_total_changes,
+
+    -- * Interrupt A Long-Running Query
+    -- <http://sqlite.org/c3ref/interrupt.html>
+
+    sqlite3_interrupt,
+
+    -- * Determine If An SQL Statement Is Complete
+    -- <http://sqlite.org/c3ref/complete.html>
+
+    sqlite3_complete,
+    sqlite3_complete16,
+
+    -- * Register A Callback To Handle SQLITE_BUSY Errors
+    -- <http://sqlite.org/c3ref/busy_handler.html>
+
+    sqlite3_busy_handler,
+
+    -- * Set A Busy Timeout
+    -- <http://sqlite.org/c3ref/busy_timeout.html>
+
+    sqlite3_busy_timeout,
+
+    -- * Convenience Routines For Running Queries
+    -- <http://sqlite.org/c3ref/free_table.html>
+
+    sqlite3_get_table,
+    sqlite3_free_table,
+
+    -- * Memory Allocation Subsystem
+    -- <http://sqlite.org/c3ref/free.html>
+
+    sqlite3_malloc,
+    sqlite3_realloc,
+    sqlite3_free,
+
+    -- * Memory Allocator Statistics
+    -- <http://sqlite.org/c3ref/memory_highwater.html>
+
+    sqlite3_memory_used,
+    sqlite3_memory_highwater,
+
+    -- * Pseudo-Random Number Generator
+    -- <http://sqlite.org/c3ref/randomness.html>
+
+    sqlite3_randomness,
+
+    -- * Compile-Time Authorization Callbacks
+    -- <http://sqlite.org/c3ref/set_authorizer.html>
+
+    sqlite3_set_authorizer,
+
+    -- * Authorizer Return Codes
+    -- <http://sqlite.org/c3ref/c_deny.html>
+
+    _SQLITE_DENY,
+    _SQLITE_IGNORE,
+
+    -- * Authorizer Action Codes
+    -- <http://sqlite.org/c3ref/c_alter_table.html>
+
+    _SQLITE_CREATE_INDEX,
+    _SQLITE_CREATE_TABLE,
+    _SQLITE_CREATE_TEMP_INDEX,
+    _SQLITE_CREATE_TEMP_TABLE,
+    _SQLITE_CREATE_TEMP_TRIGGER,
+    _SQLITE_CREATE_TEMP_VIEW,
+    _SQLITE_CREATE_TRIGGER,
+    _SQLITE_CREATE_VIEW,
+    _SQLITE_DELETE,
+    _SQLITE_DROP_INDEX,
+    _SQLITE_DROP_TABLE,
+    _SQLITE_DROP_TEMP_INDEX,
+    _SQLITE_DROP_TEMP_TABLE,
+    _SQLITE_DROP_TEMP_TRIGGER,
+    _SQLITE_DROP_TEMP_VIEW,
+    _SQLITE_DROP_TRIGGER,
+    _SQLITE_DROP_VIEW,
+    _SQLITE_INSERT,
+    _SQLITE_PRAGMA,
+    _SQLITE_READ,
+    _SQLITE_SELECT,
+    _SQLITE_TRANSACTION,
+    _SQLITE_UPDATE,
+    _SQLITE_ATTACH,
+    _SQLITE_DETACH,
+    _SQLITE_ALTER_TABLE,
+    _SQLITE_REINDEX,
+    _SQLITE_ANALYZE,
+    _SQLITE_CREATE_VTABLE,
+    _SQLITE_DROP_VTABLE,
+    _SQLITE_FUNCTION,
+    _SQLITE_SAVEPOINT,
+    _SQLITE_COPY,
+
+    -- * Query Progress Callbacks
+    -- <http://sqlite.org/c3ref/progress_handler.html>
+
+    sqlite3_progress_handler,
+
+    -- * Opening A New Database Connection
+    -- <http://sqlite.org/c3ref/open.html>
+
+    sqlite3_open,
+    sqlite3_open16,
+    sqlite3_open_v2,
+
+    -- * Error Codes And Messages
+    -- <http://sqlite.org/c3ref/errcode.html>
+
+    sqlite3_errcode,
+    sqlite3_extended_errcode,
+    sqlite3_errmsg,
+    sqlite3_errmsg16,
+
+    -- * SQL Statement Object
+    -- <http://sqlite.org/c3ref/stmt.html>
+
+    Sqlite3_stmt,
+
+    -- * Run-time Limits
+    -- <http://sqlite.org/c3ref/limit.html>
+
+    sqlite3_limit,
+
+    -- * Run-Time Limit Categories
+    -- <http://sqlite.org/c3ref/c_limit_attached.html>
+
+    _SQLITE_LIMIT_LENGTH,
+    _SQLITE_LIMIT_SQL_LENGTH,
+    _SQLITE_LIMIT_COLUMN,
+    _SQLITE_LIMIT_EXPR_DEPTH,
+    _SQLITE_LIMIT_COMPOUND_SELECT,
+    _SQLITE_LIMIT_VDBE_OP,
+    _SQLITE_LIMIT_FUNCTION_ARG,
+    _SQLITE_LIMIT_ATTACHED,
+    _SQLITE_LIMIT_LIKE_PATTERN_LENGTH,
+    _SQLITE_LIMIT_VARIABLE_NUMBER,
+
+    -- * Compiling An SQL Statement
+    -- <http://sqlite.org/c3ref/prepare.html>
+
+    sqlite3_prepare,
+    sqlite3_prepare_v2,
+    sqlite3_prepare16,
+    sqlite3_prepare16_v2,
+
+    -- * Retrieving Statement SQL
+    -- <http://sqlite.org/c3ref/sql.html>
+
+    sqlite3_sql,
+
+    -- * Dynamically Typed Value Object
+    -- <http://sqlite.org/c3ref/value.html>
+
+    Sqlite3_value,
+
+    -- * SQL Function Context Object
+    -- <http://sqlite.org/c3ref/context.html>
+
+    Sqlite3_context,
+
+    -- * Binding Values To Prepared Statements
+    -- <http://sqlite.org/c3ref/bind_blob.html>
+
+    sqlite3_bind_blob,
+    sqlite3_bind_double,
+    sqlite3_bind_int,
+    sqlite3_bind_int64,
+    sqlite3_bind_null,
+    sqlite3_bind_text,
+    sqlite3_bind_text16,
+    sqlite3_bind_value,
+    sqlite3_bind_zeroblob,
+
+    -- * Number Of SQL Parameters
+    -- <http://sqlite.org/c3ref/bind_parameter_count.html>
+
+    sqlite3_bind_parameter_count,
+
+    -- * Name Of A Host Parameter
+    -- <http://sqlite.org/c3ref/bind_parameter_name.html>
+
+    sqlite3_bind_parameter_name,
+
+    -- * Index Of A Parameter With A Given Name
+    -- <http://sqlite.org/c3ref/bind_parameter_index.html>
+
+    sqlite3_bind_parameter_index,
+
+    -- * Reset All Bindings On A Prepared Statement
+    -- <http://sqlite.org/c3ref/clear_bindings.html>
+
+    sqlite3_clear_bindings,
+
+    -- * Number Of Columns In A Result Set
+    -- <http://sqlite.org/c3ref/column_count.html>
+
+    sqlite3_column_count,
+
+    -- * Column Names In A Result Set
+    -- <http://sqlite.org/c3ref/column_name.html>
+
+    sqlite3_column_name,
+    sqlite3_column_name16,
+
+    -- * Source Of Data In A Query Result
+    -- <http://sqlite.org/c3ref/column_database_name.html>
+
+    sqlite3_column_database_name,
+    sqlite3_column_database_name16,
+    sqlite3_column_table_name,
+    sqlite3_column_table_name16,
+    sqlite3_column_origin_name,
+    sqlite3_column_origin_name16,
+
+    -- * Declared Datatype Of A Query Result
+    -- <http://sqlite.org/c3ref/column_decltype.html>
+
+    sqlite3_column_decltype,
+    sqlite3_column_decltype16,
+
+    -- * Evaluate An SQL Statement
+    -- <http://sqlite.org/c3ref/step.html>
+
+    sqlite3_step,
+
+    -- * Number of columns in a result set
+    -- <http://sqlite.org/c3ref/data_count.html>
+
+    sqlite3_data_count,
+
+    -- * Fundamental Datatypes
+    -- <http://sqlite.org/c3ref/c_blob.html>
+
+    _SQLITE_INTEGER,
+    _SQLITE_FLOAT,
+    _SQLITE_BLOB,
+    _SQLITE_NULL,
+    _SQLITE3_TEXT,
+
+    -- * Result Values From A Query
+    -- <http://sqlite.org/c3ref/column_blob.html>
+
+    sqlite3_column_blob,
+    sqlite3_column_bytes,
+    sqlite3_column_bytes16,
+    sqlite3_column_double,
+    sqlite3_column_int,
+    sqlite3_column_int64,
+    sqlite3_column_text,
+    sqlite3_column_text16,
+    sqlite3_column_type,
+    sqlite3_column_value,
+
+    -- * Destroy A Prepared Statement Object
+    -- <http://sqlite.org/c3ref/finalize.html>
+
+    sqlite3_finalize,
+
+    -- * Reset A Prepared Statement Object
+    -- <http://sqlite.org/c3ref/create_function.html>
+
+    sqlite3_create_function,
+    sqlite3_create_function16,
+
+    -- * Text Encodings
+    -- <http://sqlite.org/c3ref/c_any.html>
+
+    _SQLITE_UTF8,
+    _SQLITE_UTF16LE,
+    _SQLITE_UTF16BE,
+    _SQLITE_UTF16,
+    _SQLITE_ANY,
+    _SQLITE_UTF16_ALIGNED,
+
+    -- * Obtaining SQL Function Parameter Values
+    -- <http://sqlite.org/c3ref/value_blob.html>
+
+    sqlite3_value_blob,
+    sqlite3_value_bytes,
+    sqlite3_value_bytes16,
+    sqlite3_value_double,
+    sqlite3_value_int,
+    sqlite3_value_int64,
+    sqlite3_value_text,
+    sqlite3_value_text16,
+    sqlite3_value_text16le,
+    sqlite3_value_text16be,
+    sqlite3_value_type,
+    sqlite3_value_numeric_type,
+
+    -- * Obtain Aggregate Function Context
+    -- <http://sqlite.org/c3ref/aggregate_context.html>
+
+    sqlite3_aggregate_context,
+
+    -- * User Data For Functions
+    -- <http://sqlite.org/c3ref/user_data.html>
+
+    sqlite3_user_data,
+
+    -- * Database Connection For Functions
+    -- <http://sqlite.org/c3ref/context_db_handle.html>
+
+    sqlite3_context_db_handle,
+
+    -- * Function Auxiliary Data
+    -- <http://sqlite.org/c3ref/get_auxdata.html>
+
+    sqlite3_get_auxdata,
+    sqlite3_set_auxdata,
+
+    -- * Constants Defining Special Destructor Behavior
+    -- <http://sqlite.org/c3ref/c_static.html>
+
+    Sqlite3_destructor_type,
+    _SQLITE_STATIC,
+    _SQLITE_TRANSIENT,
+
+    -- * Setting The Result Of An SQL Function
+    -- <http://sqlite.org/c3ref/result_blob.html>
+
+    sqlite3_result_blob,
+    sqlite3_result_double,
+    sqlite3_result_error,
+    sqlite3_result_error16,
+    sqlite3_result_error_toobig,
+    sqlite3_result_error_nomem,
+    sqlite3_result_error_code,
+    sqlite3_result_int,
+    sqlite3_result_int64,
+    sqlite3_result_null,
+    sqlite3_result_text,
+    sqlite3_result_text16,
+    sqlite3_result_text16le,
+    sqlite3_result_text16be,
+    sqlite3_result_value,
+    sqlite3_result_zeroblob,
+
+    -- * Define New Collating Sequences
+    -- <http://sqlite.org/c3ref/create_collation.html>
+
+    sqlite3_create_collation,
+    sqlite3_create_collation_v2,
+    sqlite3_create_collation16,
+
+    -- * Collation Needed Callbacks
+    -- <http://sqlite.org/c3ref/collation_needed.html>
+
+    sqlite3_collation_needed,
+    sqlite3_collation_needed16,
+
+    -- * Suspend Execution For A Short Time
+    -- <http://sqlite.org/c3ref/sleep.html>
+
+    sqlite3_sleep,
+
+    -- * Name Of The Folder Holding Temporary Files
+    -- <http://sqlite.org/c3ref/temp_directory.html>
+
+    sqlite_temp_directory,
+
+    -- * Test For Auto-Commit Mode
+    -- <http://sqlite.org/c3ref/get_autocommit.html>
+
+    sqlite3_get_autocommit,
+
+    -- * Find The Database Handle Of A Prepared Statement
+    -- <http://sqlite.org/c3ref/db_handle.html>
+
+    sqlite3_db_handle,
+
+    -- * Find the next prepared statement
+    -- <http://sqlite.org/c3ref/next_stmt.html>
+
+    sqlite3_next_stmt,
+
+    -- * Commit And Rollback Notification Callbacks
+    -- <http://sqlite.org/c3ref/commit_hook.html>
+
+    sqlite3_commit_hook,
+    sqlite3_rollback_hook,
+
+    -- * Data Change Notification Callbacks
+    -- <http://sqlite.org/c3ref/update_hook.html>
+
+    sqlite3_update_hook,
+
+    -- * Enable Or Disable Shared Pager Cache
+    -- <http://sqlite.org/c3ref/enable_shared_cache.html>
+
+    sqlite3_enable_shared_cache,
+
+    -- * Attempt To Free Heap Memory
+    -- <http://sqlite.org/c3ref/release_memory.html>
+
+    sqlite3_release_memory,
+
+    -- * Impose A Limit On Heap Size
+    -- <http://sqlite.org/c3ref/soft_heap_limit.html>
+
+    sqlite3_soft_heap_limit,
+
+    -- * Load An Extension
+    -- <http://sqlite.org/c3ref/load_extension.html>
+
+    sqlite3_load_extension,
+
+    -- * Enable Or Disable Extension Loading
+    -- <http://sqlite.org/c3ref/enable_load_extension.html>
+
+    sqlite3_enable_load_extension,
+
+    -- * Automatically Load An Extensions
+    -- <http://sqlite.org/c3ref/auto_extension.html>
+
+    sqlite3_auto_extension,
+
+    -- * Reset Automatic Extension Loading
+    -- <http://sqlite.org/c3ref/reset_auto_extension.html>
+
+    sqlite3_reset_auto_extension,
+
+    -- * A Handle To An Open BLOB
+    -- <http://sqlite.org/c3ref/blob.html>
+
+    Sqlite3_blob,
+
+    -- * Open A BLOB For Incremental I/O
+    -- <http://sqlite.org/c3ref/blob_open.html>
+
+    sqlite3_blob_open,
+
+    -- * Close A BLOB Handle
+    -- <http://sqlite.org/c3ref/blob_close.html>
+
+    sqlite3_blob_close,
+
+    -- * Return The Size Of An Open BLOB
+    -- <http://sqlite.org/c3ref/blob_bytes.html>
+
+    sqlite3_blob_bytes,
+
+    -- * Read Data From A BLOB Incrementally
+    -- <http://sqlite.org/c3ref/blob_read.html>
+
+    sqlite3_blob_read,
+
+    -- * Write Data Into A BLOB Incrementally
+    -- <http://sqlite.org/c3ref/blob_write.html>
+
+    sqlite3_blob_write,
+
+    -- * Virtual File System Objects
+    -- <http://sqlite.org/c3ref/vfs_find.html>
+
+    sqlite3_vfs_find,
+    sqlite3_vfs_register,
+    sqlite3_vfs_unregister,
+
+    -- * Mutexes
+    -- <http://sqlite.org/c3ref/mutex_alloc.html>
+
+    sqlite3_mutex_alloc,
+    sqlite3_mutex_free,
+    sqlite3_mutex_enter,
+    sqlite3_mutex_try,
+    sqlite3_mutex_leave,
+
+    -- * Mutex Verification Routines
+    -- <http://sqlite.org/c3ref/mutex_held.html>
+
+    sqlite3_mutex_held,
+    sqlite3_mutex_notheld,
+
+    -- * Mutex Types
+    -- <http://sqlite.org/c3ref/c_mutex_fast.html>
+
+    _SQLITE_MUTEX_FAST,
+    _SQLITE_MUTEX_RECURSIVE,
+    _SQLITE_MUTEX_STATIC_MASTER,
+    _SQLITE_MUTEX_STATIC_MEM,
+    _SQLITE_MUTEX_STATIC_MEM2,
+    _SQLITE_MUTEX_STATIC_PRNG,
+    _SQLITE_MUTEX_STATIC_LRU,
+    _SQLITE_MUTEX_STATIC_LRU2,
+
+    -- * Retrieve the mutex for a database connection
+    -- <http://sqlite.org/c3ref/db_mutex.html>
+
+    sqlite3_db_mutex,
+
+    -- * Low-Level Control Of Database Files
+    -- <http://sqlite.org/c3ref/file_control.html>
+
+    sqlite3_file_control
+
+ ) where
+
+import Sqlite3Constants
+import Sqlite3Types
+import Sqlite3Functions
diff --git a/src/Sqlite3Constants.hs b/src/Sqlite3Constants.hs
new file mode 100644
--- /dev/null
+++ b/src/Sqlite3Constants.hs
@@ -0,0 +1,474 @@
+module Sqlite3Constants where
+import Foreign
+import Foreign.C
+import Sqlite3Types
+
+foreign import ccall "_SQLITE_OK" _SQLITE_OK
+    :: CInt
+
+foreign import ccall "_SQLITE_ERROR" _SQLITE_ERROR
+    :: CInt
+
+foreign import ccall "_SQLITE_INTERNAL" _SQLITE_INTERNAL
+    :: CInt
+
+foreign import ccall "_SQLITE_PERM" _SQLITE_PERM
+    :: CInt
+
+foreign import ccall "_SQLITE_ABORT" _SQLITE_ABORT
+    :: CInt
+
+foreign import ccall "_SQLITE_BUSY" _SQLITE_BUSY
+    :: CInt
+
+foreign import ccall "_SQLITE_LOCKED" _SQLITE_LOCKED
+    :: CInt
+
+foreign import ccall "_SQLITE_NOMEM" _SQLITE_NOMEM
+    :: CInt
+
+foreign import ccall "_SQLITE_READONLY" _SQLITE_READONLY
+    :: CInt
+
+foreign import ccall "_SQLITE_INTERRUPT" _SQLITE_INTERRUPT
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR" _SQLITE_IOERR
+    :: CInt
+
+foreign import ccall "_SQLITE_CORRUPT" _SQLITE_CORRUPT
+    :: CInt
+
+foreign import ccall "_SQLITE_NOTFOUND" _SQLITE_NOTFOUND
+    :: CInt
+
+foreign import ccall "_SQLITE_FULL" _SQLITE_FULL
+    :: CInt
+
+foreign import ccall "_SQLITE_CANTOPEN" _SQLITE_CANTOPEN
+    :: CInt
+
+foreign import ccall "_SQLITE_PROTOCOL" _SQLITE_PROTOCOL
+    :: CInt
+
+foreign import ccall "_SQLITE_EMPTY" _SQLITE_EMPTY
+    :: CInt
+
+foreign import ccall "_SQLITE_SCHEMA" _SQLITE_SCHEMA
+    :: CInt
+
+foreign import ccall "_SQLITE_TOOBIG" _SQLITE_TOOBIG
+    :: CInt
+
+foreign import ccall "_SQLITE_CONSTRAINT" _SQLITE_CONSTRAINT
+    :: CInt
+
+foreign import ccall "_SQLITE_MISMATCH" _SQLITE_MISMATCH
+    :: CInt
+
+foreign import ccall "_SQLITE_MISUSE" _SQLITE_MISUSE
+    :: CInt
+
+foreign import ccall "_SQLITE_NOLFS" _SQLITE_NOLFS
+    :: CInt
+
+foreign import ccall "_SQLITE_AUTH" _SQLITE_AUTH
+    :: CInt
+
+foreign import ccall "_SQLITE_FORMAT" _SQLITE_FORMAT
+    :: CInt
+
+foreign import ccall "_SQLITE_RANGE" _SQLITE_RANGE
+    :: CInt
+
+foreign import ccall "_SQLITE_NOTADB" _SQLITE_NOTADB
+    :: CInt
+
+foreign import ccall "_SQLITE_ROW" _SQLITE_ROW
+    :: CInt
+
+foreign import ccall "_SQLITE_DONE" _SQLITE_DONE
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_READ" _SQLITE_IOERR_READ
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_SHORT_READ" _SQLITE_IOERR_SHORT_READ
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_WRITE" _SQLITE_IOERR_WRITE
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_FSYNC" _SQLITE_IOERR_FSYNC
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_DIR_FSYNC" _SQLITE_IOERR_DIR_FSYNC
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_TRUNCATE" _SQLITE_IOERR_TRUNCATE
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_FSTAT" _SQLITE_IOERR_FSTAT
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_UNLOCK" _SQLITE_IOERR_UNLOCK
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_RDLOCK" _SQLITE_IOERR_RDLOCK
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_DELETE" _SQLITE_IOERR_DELETE
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_BLOCKED" _SQLITE_IOERR_BLOCKED
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_NOMEM" _SQLITE_IOERR_NOMEM
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_ACCESS" _SQLITE_IOERR_ACCESS
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_CHECKRESERVEDLOCK"
+ _SQLITE_IOERR_CHECKRESERVEDLOCK
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_LOCK" _SQLITE_IOERR_LOCK
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_CLOSE" _SQLITE_IOERR_CLOSE
+    :: CInt
+
+foreign import ccall "_SQLITE_IOERR_DIR_CLOSE" _SQLITE_IOERR_DIR_CLOSE
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_READONLY" _SQLITE_OPEN_READONLY
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_READWRITE" _SQLITE_OPEN_READWRITE
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_CREATE" _SQLITE_OPEN_CREATE
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_DELETEONCLOSE"
+ _SQLITE_OPEN_DELETEONCLOSE
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_EXCLUSIVE" _SQLITE_OPEN_EXCLUSIVE
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_MAIN_DB" _SQLITE_OPEN_MAIN_DB
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_TEMP_DB" _SQLITE_OPEN_TEMP_DB
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_TRANSIENT_DB"
+ _SQLITE_OPEN_TRANSIENT_DB
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_MAIN_JOURNAL"
+ _SQLITE_OPEN_MAIN_JOURNAL
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_TEMP_JOURNAL" _SQLITE_OPEN_TEMP_JOURNAL
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_SUBJOURNAL" _SQLITE_OPEN_SUBJOURNAL
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_MASTER_JOURNAL"
+ _SQLITE_OPEN_MASTER_JOURNAL
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_NOMUTEX" _SQLITE_OPEN_NOMUTEX
+    :: CInt
+
+foreign import ccall "_SQLITE_OPEN_FULLMUTEX" _SQLITE_OPEN_FULLMUTEX
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC" _SQLITE_IOCAP_ATOMIC
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC512" _SQLITE_IOCAP_ATOMIC512
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC1K" _SQLITE_IOCAP_ATOMIC1K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC2K" _SQLITE_IOCAP_ATOMIC2K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC4K" _SQLITE_IOCAP_ATOMIC4K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC8K" _SQLITE_IOCAP_ATOMIC8K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC16K" _SQLITE_IOCAP_ATOMIC16K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC32K" _SQLITE_IOCAP_ATOMIC32K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_ATOMIC64K" _SQLITE_IOCAP_ATOMIC64K
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_SAFE_APPEND"
+ _SQLITE_IOCAP_SAFE_APPEND
+    :: CInt
+
+foreign import ccall "_SQLITE_IOCAP_SEQUENTIAL" _SQLITE_IOCAP_SEQUENTIAL
+    :: CInt
+
+foreign import ccall "_SQLITE_LOCK_NONE" _SQLITE_LOCK_NONE
+    :: CInt
+
+foreign import ccall "_SQLITE_LOCK_SHARED" _SQLITE_LOCK_SHARED
+    :: CInt
+
+foreign import ccall "_SQLITE_LOCK_RESERVED" _SQLITE_LOCK_RESERVED
+    :: CInt
+
+foreign import ccall "_SQLITE_LOCK_PENDING" _SQLITE_LOCK_PENDING
+    :: CInt
+
+foreign import ccall "_SQLITE_LOCK_EXCLUSIVE" _SQLITE_LOCK_EXCLUSIVE
+    :: CInt
+
+foreign import ccall "_SQLITE_SYNC_NORMAL" _SQLITE_SYNC_NORMAL
+    :: CInt
+
+foreign import ccall "_SQLITE_SYNC_FULL" _SQLITE_SYNC_FULL
+    :: CInt
+
+foreign import ccall "_SQLITE_SYNC_DATAONLY" _SQLITE_SYNC_DATAONLY
+    :: CInt
+
+foreign import ccall "_SQLITE_FCNTL_LOCKSTATE" _SQLITE_FCNTL_LOCKSTATE
+  
+    :: CInt
+
+foreign import ccall "_SQLITE_GET_LOCKPROXYFILE"
+ _SQLITE_GET_LOCKPROXYFILE
+    :: CInt
+
+foreign import ccall "_SQLITE_SET_LOCKPROXYFILE"
+ _SQLITE_SET_LOCKPROXYFILE
+    :: CInt
+
+foreign import ccall "_SQLITE_LAST_ERRNO" _SQLITE_LAST_ERRNO
+    :: CInt
+
+foreign import ccall "_SQLITE_ACCESS_EXISTS" _SQLITE_ACCESS_EXISTS
+    :: CInt
+
+foreign import ccall "_SQLITE_ACCESS_READWRITE" _SQLITE_ACCESS_READWRITE
+    :: CInt
+
+foreign import ccall "_SQLITE_ACCESS_READ" _SQLITE_ACCESS_READ
+    :: CInt
+
+foreign import ccall "_SQLITE_DENY" _SQLITE_DENY
+    :: CInt
+
+foreign import ccall "_SQLITE_IGNORE" _SQLITE_IGNORE
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_INDEX" _SQLITE_CREATE_INDEX
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_TABLE" _SQLITE_CREATE_TABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_TEMP_INDEX" _SQLITE_CREATE_TEMP_INDEX
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_TEMP_TABLE" _SQLITE_CREATE_TEMP_TABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_TEMP_TRIGGER"
+ _SQLITE_CREATE_TEMP_TRIGGER
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_TEMP_VIEW" _SQLITE_CREATE_TEMP_VIEW
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_TRIGGER" _SQLITE_CREATE_TRIGGER
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_VIEW" _SQLITE_CREATE_VIEW
+    :: CInt
+
+foreign import ccall "_SQLITE_DELETE" _SQLITE_DELETE
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_INDEX" _SQLITE_DROP_INDEX
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_TABLE" _SQLITE_DROP_TABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_TEMP_INDEX" _SQLITE_DROP_TEMP_INDEX
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_TEMP_TABLE" _SQLITE_DROP_TEMP_TABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_TEMP_TRIGGER" _SQLITE_DROP_TEMP_TRIGGER
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_TEMP_VIEW" _SQLITE_DROP_TEMP_VIEW
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_TRIGGER" _SQLITE_DROP_TRIGGER
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_VIEW" _SQLITE_DROP_VIEW
+    :: CInt
+
+foreign import ccall "_SQLITE_INSERT" _SQLITE_INSERT
+    :: CInt
+
+foreign import ccall "_SQLITE_PRAGMA" _SQLITE_PRAGMA
+    :: CInt
+
+foreign import ccall "_SQLITE_READ" _SQLITE_READ
+    :: CInt
+
+foreign import ccall "_SQLITE_SELECT" _SQLITE_SELECT
+    :: CInt
+
+foreign import ccall "_SQLITE_TRANSACTION" _SQLITE_TRANSACTION
+    :: CInt
+
+foreign import ccall "_SQLITE_UPDATE" _SQLITE_UPDATE
+    :: CInt
+
+foreign import ccall "_SQLITE_ATTACH" _SQLITE_ATTACH
+    :: CInt
+
+foreign import ccall "_SQLITE_DETACH" _SQLITE_DETACH
+    :: CInt
+
+foreign import ccall "_SQLITE_ALTER_TABLE" _SQLITE_ALTER_TABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_REINDEX" _SQLITE_REINDEX
+    :: CInt
+
+foreign import ccall "_SQLITE_ANALYZE" _SQLITE_ANALYZE
+    :: CInt
+
+foreign import ccall "_SQLITE_CREATE_VTABLE" _SQLITE_CREATE_VTABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_DROP_VTABLE" _SQLITE_DROP_VTABLE
+    :: CInt
+
+foreign import ccall "_SQLITE_FUNCTION" _SQLITE_FUNCTION
+    :: CInt
+
+foreign import ccall "_SQLITE_SAVEPOINT" _SQLITE_SAVEPOINT
+    :: CInt
+
+foreign import ccall "_SQLITE_COPY" _SQLITE_COPY
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_LENGTH" _SQLITE_LIMIT_LENGTH
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_SQL_LENGTH" _SQLITE_LIMIT_SQL_LENGTH
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_COLUMN" _SQLITE_LIMIT_COLUMN
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_EXPR_DEPTH" _SQLITE_LIMIT_EXPR_DEPTH
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_COMPOUND_SELECT" _SQLITE_LIMIT_COMPOUND_SELECT
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_VDBE_OP" _SQLITE_LIMIT_VDBE_OP
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_FUNCTION_ARG" _SQLITE_LIMIT_FUNCTION_ARG
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_ATTACHED" _SQLITE_LIMIT_ATTACHED
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_LIKE_PATTERN_LENGTH"
+ _SQLITE_LIMIT_LIKE_PATTERN_LENGTH
+    :: CInt
+
+foreign import ccall "_SQLITE_LIMIT_VARIABLE_NUMBER"
+ _SQLITE_LIMIT_VARIABLE_NUMBER
+    :: CInt
+
+foreign import ccall "_SQLITE_INTEGER" _SQLITE_INTEGER
+    :: CInt
+
+foreign import ccall "_SQLITE_FLOAT" _SQLITE_FLOAT
+    :: CInt
+
+foreign import ccall "_SQLITE_BLOB" _SQLITE_BLOB
+    :: CInt
+
+foreign import ccall "_SQLITE_NULL" _SQLITE_NULL
+    :: CInt
+
+foreign import ccall "_SQLITE3_TEXT" _SQLITE3_TEXT
+    :: CInt
+
+foreign import ccall "_SQLITE_UTF8" _SQLITE_UTF8
+    :: CInt
+
+foreign import ccall "_SQLITE_UTF16LE" _SQLITE_UTF16LE
+    :: CInt
+
+foreign import ccall "_SQLITE_UTF16BE" _SQLITE_UTF16BE
+    :: CInt
+
+foreign import ccall "_SQLITE_UTF16" _SQLITE_UTF16
+    :: CInt
+
+foreign import ccall "_SQLITE_ANY" _SQLITE_ANY
+    :: CInt
+
+foreign import ccall "_SQLITE_UTF16_ALIGNED" _SQLITE_UTF16_ALIGNED
+    :: CInt
+
+foreign import ccall "_SQLITE_STATIC" _SQLITE_STATIC
+    :: Sqlite3_destructor_type a
+
+foreign import ccall "_SQLITE_TRANSIENT" _SQLITE_TRANSIENT
+    :: Sqlite3_destructor_type a
+
+foreign import ccall "_SQLITE_MUTEX_FAST" _SQLITE_MUTEX_FAST
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_RECURSIVE" _SQLITE_MUTEX_RECURSIVE
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_STATIC_MASTER"
+ _SQLITE_MUTEX_STATIC_MASTER
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_STATIC_MEM" _SQLITE_MUTEX_STATIC_MEM
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_STATIC_MEM2" _SQLITE_MUTEX_STATIC_MEM2
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_STATIC_PRNG" _SQLITE_MUTEX_STATIC_PRNG
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_STATIC_LRU" _SQLITE_MUTEX_STATIC_LRU
+    :: CInt
+
+foreign import ccall "_SQLITE_MUTEX_STATIC_LRU2" _SQLITE_MUTEX_STATIC_LRU2
+    :: CInt
+
diff --git a/src/Sqlite3Functions.hs b/src/Sqlite3Functions.hs
new file mode 100644
--- /dev/null
+++ b/src/Sqlite3Functions.hs
@@ -0,0 +1,521 @@
+module Sqlite3Functions where
+import Foreign
+import Foreign.C
+import Bindings.Utilities
+import Sqlite3Types
+
+foreign import ccall "_sqlite3_version" sqlite3_version
+    :: CString
+
+foreign import ccall "sqlite3_libversion" sqlite3_libversion
+    :: IO CString
+
+foreign import ccall "sqlite3_libversion_number" sqlite3_libversion_number
+    :: CInt
+
+foreign import ccall "sqlite3_threadsafe" sqlite3_threadsafe
+    :: IO CInt
+
+foreign import ccall "sqlite3_close" sqlite3_close
+    :: Ptr Sqlite3 -> CInt
+
+foreign import ccall "sqlite3_exec" sqlite3_exec
+    :: Ptr Sqlite3 -> CString -> FunPtr (Ptr a -> CInt ->
+       Ptr CString -> Ptr CString -> IO CInt) -> Ptr a ->
+       Ptr CString -> IO CInt
+
+foreign import ccall "sqlite3_initialize" sqlite3_initialize
+    :: CInt
+
+foreign import ccall "sqlite3_shutdown" sqlite3_shutdown
+    :: CInt
+
+foreign import ccall "sqlite3_os_init" sqlite3_os_init
+    :: CInt
+
+foreign import ccall "sqlite3_os_end" sqlite3_os_end
+    :: CInt
+
+foreign import ccall "sqlite3_extended_result_codes" 
+ sqlite3_extended_result_codes
+    :: Ptr Sqlite3 -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_last_insert_rowid" 
+ sqlite3_last_insert_rowid
+    :: Ptr Sqlite3 -> IO Int64
+
+foreign import ccall "sqlite3_changes" sqlite3_changes
+    :: Ptr Sqlite3 -> IO CInt
+
+foreign import ccall "sqlite3_total_changes" sqlite3_total_changes
+    :: Ptr Sqlite3 -> IO CInt
+
+foreign import ccall "sqlite3_interrupt" sqlite3_interrupt
+    :: Ptr Sqlite3 -> IO ()
+
+foreign import ccall "sqlite3_complete" sqlite3_complete
+    :: CString -> IO CInt
+
+foreign import ccall "sqlite3_complete16" sqlite3_complete16
+    :: Ptr () -> IO CInt
+
+foreign import ccall "sqlite3_busy_handler" sqlite3_busy_handler
+    :: Ptr Sqlite3 -> FunPtr (Ptr a -> CInt -> IO CInt) ->
+       Ptr a -> IO CInt
+
+foreign import ccall "sqlite3_busy_timeout" sqlite3_busy_timeout
+    :: Ptr Sqlite3 -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_get_table" sqlite3_get_table
+    :: Ptr Sqlite3 -> CString -> Ptr (Ptr CString) ->
+       Ptr CInt -> Ptr CInt -> Ptr CString -> IO CInt
+
+foreign import ccall "sqlite3_free_table" sqlite3_free_table
+    :: Ptr CString -> IO ()
+
+foreign import ccall "sqlite3_malloc" sqlite3_malloc
+    :: CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_realloc" sqlite3_realloc
+    :: Ptr () -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_free" sqlite3_free
+    :: Ptr () -> IO ()
+
+foreign import ccall "sqlite3_memory_used" sqlite3_memory_used
+    :: IO Int64
+
+foreign import ccall "sqlite3_memory_highwater" sqlite3_memory_highwater
+    :: CInt -> IO Int64
+
+foreign import ccall "sqlite3_randomness" sqlite3_randomness
+    :: CInt -> Ptr () -> IO ()
+
+foreign import ccall "sqlite3_set_authorizer" sqlite3_set_authorizer
+    :: Ptr Sqlite3 -> FunPtr (Ptr a -> CInt -> CString ->
+       CString -> CString -> CString -> IO CInt) -> Ptr a -> IO CInt
+
+foreign import ccall "sqlite3_progress_handler" sqlite3_progress_handler
+    :: Ptr Sqlite3 -> CInt -> FunPtr (Ptr a -> IO CInt) ->
+       Ptr a -> IO ()
+
+foreign import ccall "sqlite3_open" sqlite3_open
+    :: CString -> Ptr (Ptr Sqlite3) -> IO CInt
+
+foreign import ccall "sqlite3_open16" sqlite3_open16
+    :: Ptr () -> Ptr (Ptr Sqlite3) -> IO CInt
+
+foreign import ccall "sqlite3_open_v2" sqlite3_open_v2
+    :: CString -> Ptr (Ptr Sqlite3) -> CInt -> CString -> IO CInt
+
+foreign import ccall "sqlite3_errcode" sqlite3_errcode
+    :: Ptr Sqlite3 -> IO CInt
+
+foreign import ccall "sqlite3_extended_errcode" sqlite3_extended_errcode
+    :: Ptr Sqlite3 -> IO CInt
+
+foreign import ccall "sqlite3_errmsg" sqlite3_errmsg
+    :: Ptr Sqlite3 -> IO CString
+
+foreign import ccall "sqlite3_errmsg16" sqlite3_errmsg16
+    :: Ptr Sqlite3 -> IO (Ptr ())
+
+foreign import ccall "sqlite3_limit" sqlite3_limit
+    :: Ptr Sqlite3 -> CInt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_prepare" sqlite3_prepare
+    :: Ptr Sqlite3 -> CString -> CInt -> Ptr (Ptr Sqlite3_stmt) ->
+       Ptr CString -> IO CInt
+
+foreign import ccall "sqlite3_prepare_v2" sqlite3_prepare_v2
+    :: Ptr Sqlite3 -> CString -> CInt -> Ptr (Ptr Sqlite3) ->
+       Ptr CString -> IO CInt
+
+foreign import ccall "sqlite3_prepare16" sqlite3_prepare16
+    :: Ptr Sqlite3 -> Ptr () -> CInt -> Ptr (Ptr Sqlite3_stmt) ->
+       Ptr (Ptr ()) -> IO CInt
+
+foreign import ccall "sqlite3_prepare16_v2" sqlite3_prepare16_v2
+    :: Ptr Sqlite3 -> Ptr () -> CInt -> Ptr (Ptr Sqlite3_stmt) ->
+       Ptr (Ptr ()) -> IO CInt
+
+foreign import ccall "sqlite3_sql" sqlite3_sql
+    :: Ptr Sqlite3_stmt -> IO CString
+
+foreign import ccall "sqlite3_bind_blob" sqlite3_bind_blob
+    :: Ptr Sqlite3_stmt -> CInt -> Ptr () ->
+       CInt -> Sqlite3_destructor_type ()-> IO CInt
+
+foreign import ccall "sqlite3_bind_double" sqlite3_bind_double
+    :: Ptr Sqlite3_stmt -> CInt -> CDouble -> IO CInt
+
+foreign import ccall "sqlite3_bind_int" sqlite3_bind_int
+    :: Ptr Sqlite3_stmt -> CInt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_bind_int64" sqlite3_bind_int64
+    :: Ptr Sqlite3_stmt -> CInt -> Int64 -> IO CInt
+
+foreign import ccall "sqlite3_bind_null" sqlite3_bind_null
+    :: Ptr Sqlite3_stmt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_bind_text" sqlite3_bind_text
+    :: Ptr Sqlite3_stmt -> CInt -> CString -> CInt ->
+       Sqlite3_destructor_type CString -> IO CInt
+
+foreign import ccall "sqlite3_bind_text16" sqlite3_bind_text16
+    :: Ptr Sqlite3_stmt -> CInt -> Ptr () -> CInt ->
+       Sqlite3_destructor_type ()-> IO CInt
+
+foreign import ccall "sqlite3_bind_value" sqlite3_bind_value
+    :: Ptr Sqlite3_stmt -> CInt -> Ptr Sqlite3_value -> IO CInt
+
+foreign import ccall "sqlite3_bind_zeroblob" sqlite3_bind_zeroblob
+    :: Ptr Sqlite3_stmt -> CInt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_bind_parameter_count"
+ sqlite3_bind_parameter_count
+    :: Ptr Sqlite3_stmt -> IO CInt
+
+foreign import ccall "sqlite3_bind_parameter_name"
+ sqlite3_bind_parameter_name
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_bind_parameter_index"
+ sqlite3_bind_parameter_index
+    :: Ptr Sqlite3_stmt -> CString -> IO CInt
+
+foreign import ccall "sqlite3_clear_bindings" sqlite3_clear_bindings
+    :: Ptr Sqlite3_stmt -> IO CInt
+
+foreign import ccall "sqlite3_column_count" sqlite3_column_count
+    :: Ptr Sqlite3_stmt -> IO CInt
+
+foreign import ccall "sqlite3_column_name" sqlite3_column_name
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_column_name16" sqlite3_column_name16
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_column_database_name"
+ sqlite3_column_database_name
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_column_database_name16"
+ sqlite3_column_database_name16
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_column_table_name"
+ sqlite3_column_table_name
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_column_table_name16"
+ sqlite3_column_table_name16
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_column_origin_name"
+ sqlite3_column_origin_name
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_column_origin_name16"
+ sqlite3_column_origin_name16
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_column_decltype"
+ sqlite3_column_decltype
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_column_decltype16"
+ sqlite3_column_decltype16
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_step" sqlite3_step
+    :: Ptr Sqlite3_stmt -> IO CInt
+
+foreign import ccall "sqlite3_data_count" sqlite3_data_count
+    :: Ptr Sqlite3_stmt -> IO CInt
+
+foreign import ccall "sqlite3_column_blob" sqlite3_column_blob
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_column_bytes" sqlite3_column_bytes
+    :: Ptr Sqlite3_stmt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_column_bytes16" sqlite3_column_bytes16
+    :: Ptr Sqlite3_stmt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_column_double" sqlite3_column_double
+    :: Ptr Sqlite3_stmt -> CInt -> IO CDouble
+
+foreign import ccall "sqlite3_column_int" sqlite3_column_int
+    :: Ptr Sqlite3_stmt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_column_int64" sqlite3_column_int64
+    :: Ptr Sqlite3_stmt -> CInt -> IO Int64
+
+foreign import ccall "sqlite3_column_text" sqlite3_column_text
+    :: Ptr Sqlite3_stmt -> CInt -> IO CString
+
+foreign import ccall "sqlite3_column_text16" sqlite3_column_text16
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_column_type" sqlite3_column_type
+    :: Ptr Sqlite3_stmt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_column_value" sqlite3_column_value
+    :: Ptr Sqlite3_stmt -> CInt -> IO (Ptr Sqlite3_value)
+
+foreign import ccall "sqlite3_finalize" sqlite3_finalize
+    :: Ptr Sqlite3_stmt -> IO CInt
+
+foreign import ccall "sqlite3_create_function" sqlite3_create_function
+    :: Ptr Sqlite3 -> CString -> CInt -> CInt -> Ptr () ->
+       FunPtr (Ptr Sqlite3_context -> CInt -> Ptr (Ptr Sqlite3_value) ->
+       IO ()) -> FunPtr (Ptr Sqlite3_context -> CInt -> Ptr
+       (Ptr Sqlite3_value) -> IO ()) -> FunPtr (Ptr Sqlite3_context ->
+       IO ()) -> IO CInt
+
+foreign import ccall "sqlite3_create_function16" sqlite3_create_function16
+    :: Ptr Sqlite3 -> Ptr () -> CInt -> CInt -> Ptr () ->
+       FunPtr (Ptr Sqlite3_context -> CInt -> Ptr (Ptr Sqlite3_value) ->
+       IO ()) -> FunPtr (Ptr Sqlite3_context -> CInt -> Ptr 
+       (Ptr Sqlite3_value) -> IO ()) -> FunPtr (Ptr Sqlite3_context ->
+       IO ()) -> IO CInt
+
+foreign import ccall "sqlite3_value_blob" sqlite3_value_blob
+    :: Ptr Sqlite3_value -> IO (Ptr ())
+
+foreign import ccall "sqlite3_value_bytes" sqlite3_value_bytes
+    :: Ptr Sqlite3_value -> IO CInt
+
+foreign import ccall "sqlite3_value_bytes16" sqlite3_value_bytes16
+    :: Ptr Sqlite3_value -> IO CInt
+
+foreign import ccall "sqlite3_value_double" sqlite3_value_double
+    :: Ptr Sqlite3_value -> IO CDouble
+
+foreign import ccall "sqlite3_value_int" sqlite3_value_int
+    :: Ptr Sqlite3_value -> IO CInt
+
+foreign import ccall "sqlite3_value_int64" sqlite3_value_int64
+    :: Ptr Sqlite3_value -> IO Int64
+
+foreign import ccall "sqlite3_value_text" sqlite3_value_text
+    :: Ptr Sqlite3_value -> IO CString
+
+foreign import ccall "sqlite3_value_text16" sqlite3_value_text16
+    :: Ptr Sqlite3_value -> IO (Ptr ())
+
+foreign import ccall "sqlite3_value_text16le" sqlite3_value_text16le
+    :: Ptr Sqlite3_value -> IO (Ptr ())
+
+foreign import ccall "sqlite3_value_text16be" sqlite3_value_text16be
+    :: Ptr Sqlite3_value -> IO (Ptr ())
+
+foreign import ccall "sqlite3_value_type" sqlite3_value_type
+    :: Ptr Sqlite3_value -> IO CInt
+
+foreign import ccall "sqlite3_value_numeric_type"
+ sqlite3_value_numeric_type
+    :: Ptr Sqlite3_value -> IO CInt
+
+foreign import ccall "sqlite3_aggregate_context"
+ sqlite3_aggregate_context
+    :: Ptr Sqlite3_context -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_user_data" sqlite3_user_data
+    :: Ptr Sqlite3_context -> IO (Ptr ())
+
+foreign import ccall "sqlite3_context_db_handle"
+ sqlite3_context_db_handle
+    :: Ptr Sqlite3_context -> IO (Ptr Sqlite3)
+
+foreign import ccall "sqlite3_get_auxdata" sqlite3_get_auxdata
+    :: Ptr Sqlite3_context -> CInt -> IO (Ptr ())
+
+foreign import ccall "sqlite3_set_auxdata" sqlite3_set_auxdata
+    :: Ptr Sqlite3_context -> CInt -> Ptr () ->
+       Sqlite3_destructor_type ()-> IO ()
+
+foreign import ccall "sqlite3_result_blob" sqlite3_result_blob
+    :: Ptr Sqlite3_context -> Ptr () -> CInt ->
+       Sqlite3_destructor_type ()-> IO ()
+
+foreign import ccall "sqlite3_result_double" sqlite3_result_double
+    :: Ptr Sqlite3_context -> CDouble -> IO ()
+
+foreign import ccall "sqlite3_result_error" sqlite3_result_error
+    :: Ptr Sqlite3_context -> CString -> CInt -> IO ()
+
+foreign import ccall "sqlite3_result_error16" sqlite3_result_error16
+    :: Ptr Sqlite3_context -> Ptr () -> CInt -> IO ()
+
+foreign import ccall "sqlite3_result_error_toobig"
+ sqlite3_result_error_toobig
+    :: Ptr Sqlite3_context -> IO ()
+
+foreign import ccall "sqlite3_result_error_nomem"
+ sqlite3_result_error_nomem
+    :: Ptr Sqlite3_context -> IO ()
+
+foreign import ccall "sqlite3_result_error_code" sqlite3_result_error_code
+    :: Ptr Sqlite3_context -> CInt -> IO ()
+
+foreign import ccall "sqlite3_result_int" sqlite3_result_int
+    :: Ptr Sqlite3_context -> CInt -> IO ()
+
+foreign import ccall "sqlite3_result_int64" sqlite3_result_int64
+    :: Ptr Sqlite3_context -> Int64 -> IO ()
+
+foreign import ccall "sqlite3_result_null" sqlite3_result_null
+    :: Ptr Sqlite3_context -> IO ()
+
+foreign import ccall "sqlite3_result_text" sqlite3_result_text
+    :: Ptr Sqlite3_context -> CString -> CInt ->
+       Sqlite3_destructor_type CString -> IO ()
+
+foreign import ccall "sqlite3_result_text16" sqlite3_result_text16
+    :: Ptr Sqlite3_context -> Ptr () -> CInt ->
+       Sqlite3_destructor_type ()-> IO ()
+
+foreign import ccall "sqlite3_result_text16le" sqlite3_result_text16le
+    :: Ptr Sqlite3_context -> Ptr () -> CInt ->
+       Sqlite3_destructor_type ()-> IO ()
+
+foreign import ccall "sqlite3_result_text16be" sqlite3_result_text16be
+    :: Ptr Sqlite3_context -> Ptr () -> CInt ->
+       Sqlite3_destructor_type ()-> IO ()
+
+foreign import ccall "sqlite3_result_value" sqlite3_result_value
+    :: Ptr Sqlite3_context -> Ptr Sqlite3_value -> IO ()
+
+foreign import ccall "sqlite3_result_zeroblob" sqlite3_result_zeroblob
+    :: Ptr Sqlite3_context -> CInt -> IO ()
+
+foreign import ccall "sqlite3_create_collation"
+ sqlite3_create_collation
+    :: Ptr Sqlite3 -> CString -> CInt -> Ptr a ->
+       FunPtr (Ptr a -> CInt -> Ptr () -> CInt -> Ptr () -> IO CInt) ->
+       IO CInt
+
+foreign import ccall "sqlite3_create_collation_v2"
+ sqlite3_create_collation_v2
+    :: Ptr Sqlite3 -> CString -> CInt -> Ptr a ->
+       FunPtr (Ptr a -> CInt -> Ptr () -> CInt -> Ptr () -> IO CInt) ->
+       Sqlite3_destructor_type a -> IO CInt
+
+foreign import ccall "sqlite3_create_collation16"
+ sqlite3_create_collation16
+    :: Ptr Sqlite3 -> Ptr () -> CInt -> Ptr a ->
+       FunPtr (Ptr a -> CInt -> Ptr () -> CInt -> Ptr () -> IO CInt) ->
+       IO CInt
+
+foreign import ccall "sqlite3_collation_needed"
+ sqlite3_collation_needed
+    :: Ptr Sqlite3 -> Ptr a -> FunPtr (Ptr a -> Ptr Sqlite3 ->
+       CInt -> CString -> IO ()) -> IO CInt
+
+foreign import ccall "sqlite3_collation_needed16"
+ sqlite3_collation_needed16
+    :: Ptr Sqlite3 -> Ptr a -> FunPtr (Ptr a -> Ptr Sqlite3 ->
+       CInt -> Ptr () -> IO ()) -> IO CInt
+
+foreign import ccall "sqlite3_sleep" sqlite3_sleep
+    :: CInt -> IO CInt
+
+foreign import ccall "&sqlite_temp_directory" sqlite_temp_directory
+    :: GlobalVariable CString
+
+foreign import ccall "sqlite3_get_autocommit" sqlite3_get_autocommit
+    :: Ptr Sqlite3 -> IO CInt
+
+foreign import ccall "sqlite3_db_handle" sqlite3_db_handle
+    :: Ptr Sqlite3_stmt -> IO (Ptr Sqlite3)
+
+foreign import ccall "sqlite3_next_stmt" sqlite3_next_stmt
+    :: Ptr Sqlite3 -> Ptr Sqlite3_stmt -> IO (Ptr Sqlite3_stmt)
+
+foreign import ccall "sqlite3_commit_hook" sqlite3_commit_hook
+    :: Ptr Sqlite3 -> FunPtr (Ptr a -> IO CInt) -> Ptr a -> IO (Ptr ())
+
+foreign import ccall "sqlite3_rollback_hook" sqlite3_rollback_hook
+    :: Ptr Sqlite3 -> FunPtr (Ptr a -> IO ()) -> Ptr a -> IO (Ptr ())
+
+foreign import ccall "sqlite3_update_hook" sqlite3_update_hook
+    :: Ptr Sqlite3 -> FunPtr (Ptr a -> CInt -> CString -> CString ->
+       Int64 -> IO ()) -> Ptr a -> IO (Ptr ())
+
+foreign import ccall "sqlite3_enable_shared_cache"
+ sqlite3_enable_shared_cache
+    :: CInt -> IO CInt
+
+foreign import ccall "sqlite3_release_memory" sqlite3_release_memory
+    :: CInt -> IO CInt
+
+foreign import ccall "sqlite3_soft_heap_limit" sqlite3_soft_heap_limit
+    :: CInt -> IO ()
+
+foreign import ccall "sqlite3_load_extension" sqlite3_load_extension
+    :: Ptr Sqlite3 -> CString -> CString -> Ptr CString -> IO CInt
+
+foreign import ccall "sqlite3_enable_load_extension"
+ sqlite3_enable_load_extension
+    :: Ptr Sqlite3 -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_auto_extension" sqlite3_auto_extension
+    :: FunPtr (IO ()) -> IO CInt
+
+foreign import ccall "sqlite3_reset_auto_extension"
+ sqlite3_reset_auto_extension
+    :: IO ()
+
+foreign import ccall "sqlite3_blob_open" sqlite3_blob_open
+    :: Ptr Sqlite3 -> CString -> CString -> CString -> Int64 -> CInt ->
+       Ptr (Ptr Sqlite3_blob) -> IO CInt
+
+foreign import ccall "sqlite3_blob_close" sqlite3_blob_close
+    :: Ptr Sqlite3_blob -> IO CInt
+
+foreign import ccall "sqlite3_blob_bytes" sqlite3_blob_bytes
+    :: Ptr Sqlite3_blob -> IO CInt
+
+foreign import ccall "sqlite3_blob_read" sqlite3_blob_read
+    :: Ptr Sqlite3_blob -> Ptr () -> CInt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_blob_write" sqlite3_blob_write
+    :: Ptr Sqlite3_blob -> Ptr () -> CInt -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_vfs_find" sqlite3_vfs_find
+    :: CString -> Ptr Sqlite3_vfs
+
+foreign import ccall "sqlite3_vfs_register" sqlite3_vfs_register
+    :: Ptr Sqlite3_vfs -> CInt -> IO CInt
+
+foreign import ccall "sqlite3_vfs_unregister" sqlite3_vfs_unregister
+    :: Ptr Sqlite3_vfs -> IO CInt
+
+foreign import ccall "sqlite3_mutex_alloc" sqlite3_mutex_alloc
+    :: CInt -> IO (Ptr Sqlite3_mutex)
+
+foreign import ccall "sqlite3_mutex_free" sqlite3_mutex_free
+    :: Ptr Sqlite3_mutex -> IO ()
+
+foreign import ccall "sqlite3_mutex_enter" sqlite3_mutex_enter
+    :: Ptr Sqlite3_mutex -> IO ()
+
+foreign import ccall "sqlite3_mutex_try" sqlite3_mutex_try
+    :: Ptr Sqlite3_mutex -> IO CInt
+
+foreign import ccall "sqlite3_mutex_leave" sqlite3_mutex_leave
+    :: Ptr Sqlite3_mutex -> IO ()
+
+foreign import ccall "sqlite3_mutex_held" sqlite3_mutex_held
+    :: Ptr Sqlite3_mutex -> IO CInt
+
+foreign import ccall "sqlite3_mutex_notheld" sqlite3_mutex_notheld
+    :: Ptr Sqlite3_mutex -> IO CInt
+
+foreign import ccall "sqlite3_db_mutex" sqlite3_db_mutex
+    :: Ptr Sqlite3 -> IO (Ptr Sqlite3_mutex)
+
+foreign import ccall "sqlite3_file_control" sqlite3_file_control
+    :: Ptr Sqlite3 -> CString -> CInt -> Ptr () -> IO CInt
diff --git a/src/Sqlite3Types.hs b/src/Sqlite3Types.hs
new file mode 100644
--- /dev/null
+++ b/src/Sqlite3Types.hs
@@ -0,0 +1,157 @@
+module Sqlite3Types where
+import Foreign
+import Foreign.C
+data Sqlite3
+
+data Sqlite3_file = Sqlite3_file
+    {sqlite3_file'pMethods    :: Ptr Sqlite3_io_methods}
+
+instance Storable Sqlite3_file where
+    sizeOf _ = fromIntegral size_of_sqlite3_file
+
+    alignment = sizeOf
+
+    peek p =
+        with nullPtr $ \p1 ->
+        c2hs_sqlite3_file p p1 >>
+        peek p1 >>= \v1 ->
+        return $ Sqlite3_file {sqlite3_file'pMethods = v1}
+
+    poke p v = hs2c_sqlite3_file p (sqlite3_file'pMethods v)
+
+data Sqlite3_io_methods = Sqlite3_io_methods {
+    sqlite3_io_methods'iVersion
+        :: CInt,
+    sqlite3_io_methods'xClose
+        :: FunPtr (Ptr Sqlite3_file -> IO CInt),
+    sqlite3_io_methods'xRead
+        :: FunPtr (Ptr Sqlite3_file -> Ptr () -> CInt -> Int64 -> IO CInt),
+    sqlite3_io_methods'xWrite
+        :: FunPtr (Ptr Sqlite3_file -> Ptr () -> CInt -> Int64 -> IO CInt),
+    sqlite3_io_methods'xTruncate
+        :: FunPtr (Ptr Sqlite3_file -> Int64 -> IO CInt),
+    sqlite3_io_methods'xSync
+        :: FunPtr (Ptr Sqlite3_file -> CInt -> IO CInt),
+    sqlite3_io_methods'xFileSize
+        :: FunPtr (Ptr Sqlite3_file -> Int64 -> IO CInt),
+    sqlite3_io_methods'xLock
+        :: FunPtr (Ptr Sqlite3_file -> CInt -> IO CInt),
+    sqlite3_io_methods'xUnlock
+        :: FunPtr (Ptr Sqlite3_file -> CInt -> IO CInt),
+    sqlite3_io_methods'xCheckReservedLock
+        :: FunPtr (Ptr Sqlite3_file -> CInt -> IO CInt),
+    sqlite3_io_methods'xFileControl
+        :: FunPtr (Ptr Sqlite3_file -> CInt -> Ptr () -> IO CInt),
+    sqlite3_io_methods'xSectorSize
+        :: FunPtr (Ptr Sqlite3_file -> IO CInt),
+    sqlite3_io_methods'xDeviceCharacteristics
+        :: FunPtr (Ptr Sqlite3_file -> IO CInt)}
+
+instance Storable Sqlite3_io_methods where
+    sizeOf _ = fromIntegral size_of_sqlite3_io_methods
+
+    alignment = sizeOf
+
+    peek p =
+        with 0 $ \p1 ->
+        with nullFunPtr $ \p2 ->
+        with nullFunPtr $ \p3 ->
+        with nullFunPtr $ \p4 ->
+        with nullFunPtr $ \p5 ->
+        with nullFunPtr $ \p6 ->
+        with nullFunPtr $ \p7 ->
+        with nullFunPtr $ \p8 ->
+        with nullFunPtr $ \p9 ->
+        with nullFunPtr $ \p10 ->
+        with nullFunPtr $ \p11 ->
+        with nullFunPtr $ \p12 ->
+        with nullFunPtr $ \p13 ->
+
+        c2hs_sqlite3_io_methods p p1 p2 p3 p4 p5 p6 p7 p8 p9
+            p10 p11 p12 p13 >>
+
+        peek p1 >>= \v1 ->
+        peek p2 >>= \v2 ->
+        peek p3 >>= \v3 ->
+        peek p4 >>= \v4 ->
+        peek p5 >>= \v5 ->
+        peek p6 >>= \v6 ->
+        peek p7 >>= \v7 ->
+        peek p8 >>= \v8 ->
+        peek p9 >>= \v9 ->
+        peek p10 >>= \v10 ->
+        peek p11 >>= \v11 ->
+        peek p12 >>= \v12 ->
+        peek p13 >>= \v13 ->
+
+        return $ Sqlite3_io_methods {
+            sqlite3_io_methods'iVersion = v1,
+            sqlite3_io_methods'xClose = v2,
+            sqlite3_io_methods'xRead = v3,
+            sqlite3_io_methods'xWrite = v4,
+            sqlite3_io_methods'xTruncate = v5,
+            sqlite3_io_methods'xSync = v6,
+            sqlite3_io_methods'xFileSize = v7,
+            sqlite3_io_methods'xLock = v8,
+            sqlite3_io_methods'xUnlock = v9,
+            sqlite3_io_methods'xCheckReservedLock = v10,
+            sqlite3_io_methods'xFileControl = v11,
+            sqlite3_io_methods'xSectorSize = v12,
+            sqlite3_io_methods'xDeviceCharacteristics = v13}
+
+    poke p v = hs2c_sqlite3_io_methods p
+        (sqlite3_io_methods'iVersion v)
+        (sqlite3_io_methods'xClose v)
+        (sqlite3_io_methods'xRead v)
+        (sqlite3_io_methods'xWrite v)
+        (sqlite3_io_methods'xTruncate v)
+        (sqlite3_io_methods'xSync v)
+        (sqlite3_io_methods'xFileSize v)
+        (sqlite3_io_methods'xLock v)
+        (sqlite3_io_methods'xUnlock v)
+        (sqlite3_io_methods'xCheckReservedLock v)
+        (sqlite3_io_methods'xFileControl v)
+        (sqlite3_io_methods'xSectorSize v)
+        (sqlite3_io_methods'xDeviceCharacteristics v)
+
+data Sqlite3_mutex
+
+data Sqlite3_vfs
+
+data Sqlite3_stmt
+
+data Sqlite3_value
+
+data Sqlite3_context
+
+newtype Sqlite3_destructor_type a =
+    Sqlite3_destructor_type (FunPtr (Ptr a -> IO ()))
+
+data Sqlite3_blob
+
+foreign import ccall "size_of_sqlite3_file" size_of_sqlite3_file
+    :: CInt
+
+foreign import ccall "size_of_sqlite3_io_methods"
+ size_of_sqlite3_io_methods
+    :: CInt
+
+foreign import ccall "hs2c_sqlite3_file" hs2c_sqlite3_file
+    :: Ptr a -> Ptr b -> IO ()
+
+foreign import ccall "c2hs_sqlite3_file" c2hs_sqlite3_file
+    :: Ptr a -> Ptr b -> IO ()
+
+foreign import ccall "hs2c_sqlite3_io_methods"
+ hs2c_sqlite3_io_methods
+    :: Ptr a -> CInt -> FunPtr b1 -> FunPtr b2 -> FunPtr b3 ->
+       FunPtr b4 -> FunPtr b5 -> FunPtr b6 -> FunPtr b7 ->
+       FunPtr b8 -> FunPtr b9 -> FunPtr b10 -> FunPtr b11 ->
+       FunPtr b12 -> IO ()
+
+foreign import ccall "c2hs_sqlite3_io_methods"
+ c2hs_sqlite3_io_methods
+    :: Ptr a -> Ptr CInt -> Ptr b1 -> Ptr b2 -> Ptr b3 ->
+       Ptr b4 -> Ptr b5 -> Ptr b6 -> Ptr b7 ->
+       Ptr b8 -> Ptr b9 -> Ptr b10 -> Ptr b11 ->
+       Ptr b12 -> IO ()
diff --git a/src/constants.c b/src/constants.c
new file mode 100644
--- /dev/null
+++ b/src/constants.c
@@ -0,0 +1,767 @@
+#include <sqlite3.h>
+
+char *_sqlite_version(void)
+{
+    return sqlite_version;
+}
+
+int _SQLITE_OK (void)
+{
+    return SQLITE_OK;
+}
+
+int _SQLITE_ERROR (void)
+{
+    return SQLITE_ERROR;
+}
+
+int _SQLITE_INTERNAL (void)
+{
+    return SQLITE_INTERNAL;
+}
+
+int _SQLITE_PERM (void)
+{
+    return SQLITE_PERM;
+}
+
+int _SQLITE_ABORT (void)
+{
+    return SQLITE_ABORT;
+}
+
+int _SQLITE_BUSY (void)
+{
+    return SQLITE_BUSY;
+}
+
+int _SQLITE_LOCKED (void)
+{
+    return SQLITE_LOCKED;
+}
+
+int _SQLITE_NOMEM (void)
+{
+    return SQLITE_NOMEM;
+}
+
+int _SQLITE_READONLY (void)
+{
+    return SQLITE_READONLY;
+}
+
+int _SQLITE_INTERRUPT (void)
+{
+    return SQLITE_INTERRUPT;
+}
+
+int _SQLITE_IOERR (void)
+{
+    return SQLITE_IOERR;
+}
+
+int _SQLITE_CORRUPT (void)
+{
+    return SQLITE_CORRUPT;
+}
+
+int _SQLITE_NOTFOUND (void)
+{
+    return SQLITE_NOTFOUND;
+}
+
+int _SQLITE_FULL (void)
+{
+    return SQLITE_FULL;
+}
+
+int _SQLITE_CANTOPEN (void)
+{
+    return SQLITE_CANTOPEN;
+}
+
+int _SQLITE_PROTOCOL (void)
+{
+    return SQLITE_PROTOCOL;
+}
+
+int _SQLITE_EMPTY (void)
+{
+    return SQLITE_EMPTY;
+}
+
+int _SQLITE_SCHEMA (void)
+{
+    return SQLITE_SCHEMA;
+}
+
+int _SQLITE_TOOBIG (void)
+{
+    return SQLITE_TOOBIG;
+}
+
+int _SQLITE_CONSTRAINT (void)
+{
+    return SQLITE_CONSTRAINT;
+}
+
+int _SQLITE_MISMATCH (void)
+{
+    return SQLITE_MISMATCH;
+}
+
+int _SQLITE_MISUSE (void)
+{
+    return SQLITE_MISUSE;
+}
+
+int _SQLITE_NOLFS (void)
+{
+    return SQLITE_NOLFS;
+}
+
+int _SQLITE_AUTH (void)
+{
+    return SQLITE_AUTH;
+}
+
+int _SQLITE_FORMAT (void)
+{
+    return SQLITE_FORMAT;
+}
+
+int _SQLITE_RANGE (void)
+{
+    return SQLITE_RANGE;
+}
+
+int _SQLITE_NOTADB (void)
+{
+    return SQLITE_NOTADB;
+}
+
+int _SQLITE_ROW (void)
+{
+    return SQLITE_ROW;
+}
+
+int _SQLITE_DONE (void)
+{
+    return SQLITE_DONE;
+}
+
+int _SQLITE_IOERR_READ (void)
+{
+    return SQLITE_IOERR_READ;
+}
+
+int _SQLITE_IOERR_SHORT_READ (void)
+{
+    return SQLITE_IOERR_SHORT_READ;
+}
+
+int _SQLITE_IOERR_WRITE (void)
+{
+    return SQLITE_IOERR_WRITE;
+}
+
+int _SQLITE_IOERR_FSYNC (void)
+{
+    return SQLITE_IOERR_FSYNC;
+}
+
+int _SQLITE_IOERR_DIR_FSYNC (void)
+{
+    return SQLITE_IOERR_DIR_FSYNC;
+}
+
+int _SQLITE_IOERR_TRUNCATE (void)
+{
+    return SQLITE_IOERR_TRUNCATE;
+}
+
+int _SQLITE_IOERR_FSTAT (void)
+{
+    return SQLITE_IOERR_FSTAT;
+}
+
+int _SQLITE_IOERR_UNLOCK (void)
+{
+    return SQLITE_IOERR_UNLOCK;
+}
+
+int _SQLITE_IOERR_RDLOCK (void)
+{
+    return SQLITE_IOERR_RDLOCK;
+}
+
+int _SQLITE_IOERR_DELETE (void)
+{
+    return SQLITE_IOERR_DELETE;
+}
+
+int _SQLITE_IOERR_BLOCKED (void)
+{
+    return SQLITE_IOERR_BLOCKED;
+}
+
+int _SQLITE_IOERR_NOMEM (void)
+{
+    return SQLITE_IOERR_NOMEM;
+}
+
+int _SQLITE_IOERR_ACCESS (void)
+{
+    return SQLITE_IOERR_ACCESS;
+}
+
+int _SQLITE_IOERR_CHECKRESERVEDLOCK (void)
+{
+    return SQLITE_IOERR_CHECKRESERVEDLOCK;
+}
+
+int _SQLITE_IOERR_LOCK (void)
+{
+    return SQLITE_IOERR_LOCK;
+}
+
+int _SQLITE_IOERR_CLOSE (void)
+{
+    return SQLITE_IOERR_CLOSE;
+}
+
+int _SQLITE_IOERR_DIR_CLOSE (void)
+{
+    return SQLITE_IOERR_DIR_CLOSE;
+}
+
+int _SQLITE_OPEN_READONLY (void)
+{
+    return SQLITE_OPEN_READONLY;
+}
+
+int _SQLITE_OPEN_READWRITE (void)
+{
+    return SQLITE_OPEN_READWRITE;
+}
+
+int _SQLITE_OPEN_CREATE (void)
+{
+    return SQLITE_OPEN_CREATE;
+}
+
+int _SQLITE_OPEN_DELETEONCLOSE (void)
+{
+    return SQLITE_OPEN_DELETEONCLOSE;
+}
+
+int _SQLITE_OPEN_EXCLUSIVE (void)
+{
+    return SQLITE_OPEN_EXCLUSIVE;
+}
+
+int _SQLITE_OPEN_MAIN_DB (void)
+{
+    return SQLITE_OPEN_MAIN_DB;
+}
+
+int _SQLITE_OPEN_TEMP_DB (void)
+{
+    return SQLITE_OPEN_TEMP_DB;
+}
+
+int _SQLITE_OPEN_TRANSIENT_DB (void)
+{
+    return SQLITE_OPEN_TRANSIENT_DB;
+}
+
+int _SQLITE_OPEN_MAIN_JOURNAL (void)
+{
+    return SQLITE_OPEN_MAIN_JOURNAL;
+}
+
+int _SQLITE_OPEN_TEMP_JOURNAL (void)
+{
+    return SQLITE_OPEN_TEMP_JOURNAL;
+}
+
+int _SQLITE_OPEN_SUBJOURNAL (void)
+{
+    return SQLITE_OPEN_SUBJOURNAL;
+}
+
+int _SQLITE_OPEN_MASTER_JOURNAL (void)
+{
+    return SQLITE_OPEN_MASTER_JOURNAL;
+}
+
+int _SQLITE_OPEN_NOMUTEX (void)
+{
+    return SQLITE_OPEN_NOMUTEX;
+}
+
+int _SQLITE_OPEN_FULLMUTEX (void)
+{
+    return SQLITE_OPEN_FULLMUTEX;
+}
+
+int _SQLITE_IOCAP_ATOMIC (void)
+{
+    return SQLITE_IOCAP_ATOMIC;
+}
+
+int _SQLITE_IOCAP_ATOMIC512 (void)
+{
+    return SQLITE_IOCAP_ATOMIC512;
+}
+
+int _SQLITE_IOCAP_ATOMIC1K (void)
+{
+    return SQLITE_IOCAP_ATOMIC1K;
+}
+
+int _SQLITE_IOCAP_ATOMIC2K (void)
+{
+    return SQLITE_IOCAP_ATOMIC2K;
+}
+
+int _SQLITE_IOCAP_ATOMIC4K (void)
+{
+    return SQLITE_IOCAP_ATOMIC4K;
+}
+
+int _SQLITE_IOCAP_ATOMIC8K (void)
+{
+    return SQLITE_IOCAP_ATOMIC8K;
+}
+
+int _SQLITE_IOCAP_ATOMIC16K (void)
+{
+    return SQLITE_IOCAP_ATOMIC16K;
+}
+
+int _SQLITE_IOCAP_ATOMIC32K (void)
+{
+    return SQLITE_IOCAP_ATOMIC32K;
+}
+
+int _SQLITE_IOCAP_ATOMIC64K (void)
+{
+    return SQLITE_IOCAP_ATOMIC64K;
+}
+
+int _SQLITE_IOCAP_SAFE_APPEND (void)
+{
+    return SQLITE_IOCAP_SAFE_APPEND;
+}
+
+int _SQLITE_IOCAP_SEQUENTIAL (void)
+{
+    return SQLITE_IOCAP_SEQUENTIAL;
+}
+
+int _SQLITE_LOCK_NONE (void)
+{
+    return SQLITE_LOCK_NONE;
+}
+
+int _SQLITE_LOCK_SHARED (void)
+{
+    return SQLITE_LOCK_SHARED;
+}
+
+int _SQLITE_LOCK_RESERVED (void)
+{
+    return SQLITE_LOCK_RESERVED;
+}
+
+int _SQLITE_LOCK_PENDING (void)
+{
+    return SQLITE_LOCK_PENDING;
+}
+
+int _SQLITE_LOCK_EXCLUSIVE (void)
+{
+    return SQLITE_LOCK_EXCLUSIVE;
+}
+
+int _SQLITE_SYNC_NORMAL (void)
+{
+    return SQLITE_SYNC_NORMAL;
+}
+
+int _SQLITE_SYNC_FULL (void)
+{
+    return SQLITE_SYNC_FULL;
+}
+
+int _SQLITE_SYNC_DATAONLY (void)
+{
+    return SQLITE_SYNC_DATAONLY;
+}
+
+int _SQLITE_FCNTL_LOCKSTATE (void)
+{
+    return SQLITE_FCNTL_LOCKSTATE;
+}
+
+int _SQLITE_GET_LOCKPROXYFILE (void)
+{
+    return SQLITE_GET_LOCKPROXYFILE;
+}
+
+int _SQLITE_SET_LOCKPROXYFILE (void)
+{
+    return SQLITE_SET_LOCKPROXYFILE;
+}
+
+int _SQLITE_LAST_ERRNO (void)
+{
+    return SQLITE_LAST_ERRNO;
+}
+
+int _SQLITE_ACCESS_EXISTS (void)
+{
+    return SQLITE_ACCESS_EXISTS;
+}
+
+int _SQLITE_ACCESS_READWRITE (void)
+{
+    return SQLITE_ACCESS_READWRITE;
+}
+
+int _SQLITE_ACCESS_READ (void)
+{
+    return SQLITE_ACCESS_READ;
+}
+
+int _SQLITE_DENY (void)
+{
+    return SQLITE_DENY;
+}
+
+int _SQLITE_IGNORE (void)
+{
+    return SQLITE_IGNORE;
+}
+
+int _SQLITE_CREATE_INDEX (void)
+{
+    return SQLITE_CREATE_INDEX;
+}
+
+int _SQLITE_CREATE_TABLE (void)
+{
+    return SQLITE_CREATE_TABLE;
+}
+
+int _SQLITE_CREATE_TEMP_INDEX (void)
+{
+    return SQLITE_CREATE_TEMP_INDEX;
+}
+
+int _SQLITE_CREATE_TEMP_TABLE (void)
+{
+    return SQLITE_CREATE_TEMP_TABLE;
+}
+
+int _SQLITE_CREATE_TEMP_TRIGGER (void)
+{
+    return SQLITE_CREATE_TEMP_TRIGGER;
+}
+
+int _SQLITE_CREATE_TEMP_VIEW (void)
+{
+    return SQLITE_CREATE_TEMP_VIEW;
+}
+
+int _SQLITE_CREATE_TRIGGER (void)
+{
+    return SQLITE_CREATE_TRIGGER;
+}
+
+int _SQLITE_CREATE_VIEW (void)
+{
+    return SQLITE_CREATE_VIEW;
+}
+
+int _SQLITE_DELETE (void)
+{
+    return SQLITE_DELETE;
+}
+
+int _SQLITE_DROP_INDEX (void)
+{
+    return SQLITE_DROP_INDEX;
+}
+
+int _SQLITE_DROP_TABLE (void)
+{
+    return SQLITE_DROP_TABLE;
+}
+
+int _SQLITE_DROP_TEMP_INDEX (void)
+{
+    return SQLITE_DROP_TEMP_INDEX;
+}
+
+int _SQLITE_DROP_TEMP_TABLE (void)
+{
+    return SQLITE_DROP_TEMP_TABLE;
+}
+
+int _SQLITE_DROP_TEMP_TRIGGER (void)
+{
+    return SQLITE_DROP_TEMP_TRIGGER;
+}
+
+int _SQLITE_DROP_TEMP_VIEW (void)
+{
+    return SQLITE_DROP_TEMP_VIEW;
+}
+
+int _SQLITE_DROP_TRIGGER (void)
+{
+    return SQLITE_DROP_TRIGGER;
+}
+
+int _SQLITE_DROP_VIEW (void)
+{
+    return SQLITE_DROP_VIEW;
+}
+
+int _SQLITE_INSERT (void)
+{
+    return SQLITE_INSERT;
+}
+
+int _SQLITE_PRAGMA (void)
+{
+    return SQLITE_PRAGMA;
+}
+
+int _SQLITE_READ (void)
+{
+    return SQLITE_READ;
+}
+
+int _SQLITE_SELECT (void)
+{
+    return SQLITE_SELECT;
+}
+
+int _SQLITE_TRANSACTION (void)
+{
+    return SQLITE_TRANSACTION;
+}
+
+int _SQLITE_UPDATE (void)
+{
+    return SQLITE_UPDATE;
+}
+
+int _SQLITE_ATTACH (void)
+{
+    return SQLITE_ATTACH;
+}
+
+int _SQLITE_DETACH (void)
+{
+    return SQLITE_DETACH;
+}
+
+int _SQLITE_ALTER_TABLE (void)
+{
+    return SQLITE_ALTER_TABLE;
+}
+
+int _SQLITE_REINDEX (void)
+{
+    return SQLITE_REINDEX;
+}
+
+int _SQLITE_ANALYZE (void)
+{
+    return SQLITE_ANALYZE;
+}
+
+int _SQLITE_CREATE_VTABLE (void)
+{
+    return SQLITE_CREATE_VTABLE;
+}
+
+int _SQLITE_DROP_VTABLE (void)
+{
+    return SQLITE_DROP_VTABLE;
+}
+
+int _SQLITE_FUNCTION (void)
+{
+    return SQLITE_FUNCTION;
+}
+
+int _SQLITE_SAVEPOINT (void)
+{
+    return SQLITE_SAVEPOINT;
+}
+
+int _SQLITE_COPY (void)
+{
+    return SQLITE_COPY;
+}
+
+int _SQLITE_LIMIT_LENGTH (void)
+{
+    return SQLITE_LIMIT_LENGTH;
+}
+
+int _SQLITE_LIMIT_SQL_LENGTH (void)
+{
+    return SQLITE_LIMIT_SQL_LENGTH;
+}
+
+int _SQLITE_LIMIT_COLUMN (void)
+{
+    return SQLITE_LIMIT_COLUMN;
+}
+
+int _SQLITE_LIMIT_EXPR_DEPTH (void)
+{
+    return SQLITE_LIMIT_EXPR_DEPTH;
+}
+
+int _SQLITE_LIMIT_COMPOUND_SELECT (void)
+{
+    return SQLITE_LIMIT_COMPOUND_SELECT;
+}
+
+int _SQLITE_LIMIT_VDBE_OP (void)
+{
+    return SQLITE_LIMIT_VDBE_OP;
+}
+
+int _SQLITE_LIMIT_FUNCTION_ARG (void)
+{
+    return SQLITE_LIMIT_FUNCTION_ARG;
+}
+
+int _SQLITE_LIMIT_ATTACHED (void)
+{
+    return SQLITE_LIMIT_ATTACHED;
+}
+
+int _SQLITE_LIMIT_LIKE_PATTERN_LENGTH (void)
+{
+    return SQLITE_LIMIT_LIKE_PATTERN_LENGTH;
+}
+
+int _SQLITE_LIMIT_VARIABLE_NUMBER (void)
+{
+    return SQLITE_LIMIT_VARIABLE_NUMBER;
+}
+
+int _SQLITE_INTEGER (void)
+{
+    return SQLITE_INTEGER;
+}
+
+int _SQLITE_FLOAT (void)
+{
+    return SQLITE_FLOAT;
+}
+
+int _SQLITE_BLOB (void)
+{
+    return SQLITE_BLOB;
+}
+
+int _SQLITE_NULL (void)
+{
+    return SQLITE_NULL;
+}
+
+int _SQLITE3_TEXT (void)
+{
+    return SQLITE3_TEXT;
+}
+
+int _SQLITE_UTF8 (void)
+{
+    return SQLITE_UTF8;
+}
+
+int _SQLITE_UTF16LE (void)
+{
+    return SQLITE_UTF16LE;
+}
+
+int _SQLITE_UTF16BE (void)
+{
+    return SQLITE_UTF16BE;
+}
+
+int _SQLITE_UTF16 (void)
+{
+    return SQLITE_UTF16;
+}
+
+int _SQLITE_ANY (void)
+{
+    return SQLITE_ANY;
+}
+
+int _SQLITE_UTF16_ALIGNED (void)
+{
+    return SQLITE_UTF16_ALIGNED;
+}
+
+sqlite3_destructor_type _SQLITE_STATIC (void)
+{
+    return SQLITE_STATIC;
+}
+
+sqlite3_destructor_type _SQLITE_TRANSIENT (void)
+{
+    return SQLITE_TRANSIENT;
+}
+
+int _SQLITE_MUTEX_FAST (void)
+{
+    return SQLITE_MUTEX_FAST;
+}
+
+int _SQLITE_MUTEX_RECURSIVE (void)
+{
+    return SQLITE_MUTEX_RECURSIVE;
+}
+
+int _SQLITE_MUTEX_STATIC_MASTER (void)
+{
+    return SQLITE_MUTEX_STATIC_MASTER;
+}
+
+int _SQLITE_MUTEX_STATIC_MEM (void)
+{
+    return SQLITE_MUTEX_STATIC_MEM;
+}
+
+int _SQLITE_MUTEX_STATIC_MEM2 (void)
+{
+    return SQLITE_MUTEX_STATIC_MEM2;
+}
+
+int _SQLITE_MUTEX_STATIC_PRNG (void)
+{
+    return SQLITE_MUTEX_STATIC_PRNG;
+}
+
+int _SQLITE_MUTEX_STATIC_LRU (void)
+{
+    return SQLITE_MUTEX_STATIC_LRU;
+}
+
+int _SQLITE_MUTEX_STATIC_LRU2 (void)
+{
+    return SQLITE_MUTEX_STATIC_LRU2;
+}
+
diff --git a/src/types.c b/src/types.c
new file mode 100644
--- /dev/null
+++ b/src/types.c
@@ -0,0 +1,84 @@
+#include <sqlite3.h>
+
+int size_of_sqlite3_file (void)
+{
+    return sizeof sqlite3_file;
+}
+
+int size_of_sqlite3_io_methods (void)
+{
+    return sizeof sqlite3_io_methods;
+}
+
+void hs2c_sqlite3_file (sqlite3_file *p,
+    const struct sqlite3_io_methods *p1)
+{
+    p->pMethods = p1;
+}
+
+void hs2c_sqlite_io_methods (sqlite_io_methods *p,
+    int p1,
+    int (*p2)(sqlite3_file*),
+    int (*p3)(sqlite3_file*,void*,int,sqlite3_int64),
+    int (*p4)(sqlite3_file*,const void*,int,sqlite3_int64),
+    int (*p5)(sqlite3_file*,sqlite3_int64),
+    int (*p6)(sqlite3_file*,int),
+    int (*p7)(sqlite3_file*,sqlite3_int64*),
+    int (*p8)(sqlite3_file*,int),
+    int (*p9)(sqlite3_file*,int),
+    int (*p10)(sqlite3_file*,int*),
+    int (*p11)(sqlite3_file*,int,void*),
+    int (*p12)(sqlite3_file*),
+    int (*p13)(sqlite3_file*))
+{
+    p->iVersion = p1;
+    p->xClose = p2;
+    p->xRead = p3;
+    p->xWrite = p4;
+    p->xTruncate = p5;
+    p->xSync = p6;
+    p->xFileSize = p7;
+    p->xLock = p8;
+    p->xUnlock = p9;
+    p->xCheckReservedLock = p10;
+    p->xFileControl = p11;
+    p->xSectorSize = p12;
+    p->xDeviceCharacteristics = p13;
+}
+
+void c2hs_sqlite3_file (sqlite3_file *p,
+    const struct sqlite3_io_methods **p1)
+{
+    p->pMethods = p1;
+}
+
+void c2hs_sqlite_io_methods (sqlite_io_methods *p,
+    int *p1,
+    int (**p2)(sqlite3_file*),
+    int (**p3)(sqlite3_file*,void*,int,sqlite3_int64),
+    int (**p4)(sqlite3_file*,const void*,int,sqlite3_int64),
+    int (**p5)(sqlite3_file*,sqlite3_int64),
+    int (**p6)(sqlite3_file*,int),
+    int (**p7)(sqlite3_file*,sqlite3_int64*),
+    int (**p8)(sqlite3_file*,int),
+    int (**p9)(sqlite3_file*,int),
+    int (**p10)(sqlite3_file*,int*),
+    int (**p11)(sqlite3_file*,int,void*),
+    int (**p12)(sqlite3_file*),
+    int (**p13)(sqlite3_file*))
+{
+    *p1 = p->iVersion;
+    *p2 = p->xClose;
+    *p3 = p->xRead;
+    *p4 = p->xWrite;
+    *p5 = p->xTruncate;
+    *p6 = p->xSync;
+    *p7 = p->xFileSize;
+    *p8 = p->xLock;
+    *p9 = p->xUnlock;
+    *p10 = p->xCheckReservedLock;
+    *p11 = p->xFileControl;
+    *p12 = p->xSectorSize;
+    *p13 = p->xDeviceCharacteristics;
+}
+
