Database Independent Abstraction Layer for C

libdbi Programmer's Guide

David A. Parker

Neon Goat Productions

Markus Hoenicka

libdbi implements a database-independent abstraction layer in C, similar to the DBI/DBD layer in Perl. Writing one generic set of code, programmers can leverage the power of multiple databases and multiple simultaneous database connections by using this framework.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in Appendix A.


Table of Contents
1. Introduction
1.1. Description
1.2. libdbi Concepts and Terminology
1.3. Modifications and redistribution of libdbi
1.4. Contact Info
2. Building and Installing libdbi
3. libdbi in a Nutshell (Quickstart Guide)
3.1. Quick Overview
3.2. Generic Example Program
3.3. Loading libdbi at runtime
3.4. Using libdbi in multithreaded applications
3.5. Adding libdbi to your project
4. Error Handling
4.1. Connection error numbers and messages
4.2. Error numbers
5. Transactions and Savepoints
5.1. Transactions
5.2. Savepoints
6. Library and Interface Versions
6.1. Package and library versions
6.2. libdbi and libdbi-drivers versions
6.3. Determining the library version at runtime
7. libdbi API Reference
7.1. Instance Infrastructure
7.1.1. dbi_initialize_r
7.1.2. dbi_initialize
7.1.3. dbi_shutdown_r
7.1.4. dbi_shutdown
7.1.5. dbi_set_verbosity_r
7.1.6. dbi_set_verbosity
7.1.7. dbi_version
7.1.8. dbi_version_numeric
7.2. Driver Infrastructure
7.2.1. dbi_driver_list_r
7.2.2. dbi_driver_list
7.2.3. dbi_driver_open_r
7.2.4. dbi_driver_open
7.2.5. dbi_driver_get_instance
7.2.6. dbi_driver_is_reserved_word
7.2.7. dbi_driver_specific_function
7.2.8. dbi_driver_quote_string
7.2.9. dbi_driver_quote_string_copy
7.2.10. dbi_driver_encoding_from_iana
7.2.11. dbi_driver_encoding_to_iana
7.2.12. Driver Information
7.2.12.1. dbi_driver_get_name
7.2.12.2. dbi_driver_get_filename
7.2.12.3. dbi_driver_get_description
7.2.12.4. dbi_driver_get_maintainer
7.2.12.5. dbi_driver_get_url
7.2.12.6. dbi_driver_get_version
7.2.12.7. dbi_driver_get_date_compiled
7.2.12.8. dbi_driver_cap_get
7.3. Connection Infrastructure
7.3.1. dbi_conn_new_r
7.3.2. dbi_conn_new
7.3.3. dbi_conn_open
7.3.4. dbi_conn_close
7.3.5. dbi_conn_get_driver
7.3.6. dbi_conn_set_option
7.3.7. dbi_conn_set_option_numeric
7.3.8. dbi_conn_get_option
7.3.9. dbi_conn_require_option
7.3.10. dbi_conn_get_option_numeric
7.3.11. dbi_conn_require_option_numeric
7.3.12. dbi_conn_get_option_list
7.3.13. dbi_conn_clear_option
7.3.14. dbi_conn_clear_options
7.3.15. dbi_conn_cap_get
7.3.16. dbi_conn_get_socket
7.3.17. dbi_conn_get_encoding
7.3.18. dbi_conn_get_engine_version_string
7.3.19. dbi_conn_get_engine_version
7.3.20. Error Handling
7.3.20.1. dbi_conn_error
7.3.20.2. dbi_conn_error_handler
7.3.20.3. dbi_conn_error_flag
7.3.20.4. dbi_conn_set_error
7.3.21. Transactions and Savepoints
7.3.21.1. dbi_conn_transaction_begin
7.3.21.2. dbi_conn_transaction_commit
7.3.21.3. dbi_conn_transaction_rollback
7.3.21.4. dbi_conn_savepoint
7.3.21.5. dbi_conn_rollback_to_savepoint
7.3.21.6. dbi_conn_release_savepoint
7.4. SQL and Database Infrastructure
7.4.1. dbi_conn_connect
7.4.2. dbi_conn_get_db_list
7.4.3. dbi_conn_get_table_list
7.4.4. dbi_conn_select_db
7.5. Managing Queries
7.5.1. dbi_conn_query
7.5.2. dbi_conn_queryf
7.5.3. dbi_conn_query_null
7.5.4. dbi_conn_sequence_last
7.5.5. dbi_conn_sequence_next
7.5.6. dbi_conn_ping
7.5.7. dbi_conn_quote_string
7.5.8. dbi_conn_quote_string_copy
7.5.9. dbi_conn_quote_binary_copy
7.5.10. dbi_conn_escape_string
7.5.11. dbi_conn_escape_string_copy
7.5.12. dbi_conn_escape_binary_copy
7.6. Managing Results
7.6.1. dbi_result_get_conn
7.6.2. dbi_result_free
7.6.3. dbi_result_seek_row
7.6.4. dbi_result_first_row
7.6.5. dbi_result_last_row
7.6.6. dbi_result_prev_row
7.6.7. dbi_result_next_row
7.6.8. dbi_result_get_currow
7.6.9. dbi_result_get_numrows
7.6.10. dbi_result_get_numrows_affected
7.7. Retrieving Field Meta-data
7.7.1. dbi_result_get_field_length
7.7.2. dbi_result_get_field_length_idx
7.7.3. dbi_result_get_field_size
7.7.4. dbi_result_get_field_size_idx
7.7.5. dbi_result_get_field_idx
7.7.6. dbi_result_get_field_name
7.7.7. dbi_result_get_numfields
7.7.8. dbi_result_get_field_type
7.7.9. dbi_result_get_field_type_idx
7.7.10. dbi_result_get_field_attrib
7.7.11. dbi_result_get_field_attrib_idx
7.7.12. dbi_result_get_field_attribs
7.7.13. dbi_result_get_field_attribs_idx
7.7.14. dbi_result_field_is_null
7.7.15. dbi_result_field_is_null_idx
7.8. Retrieving Field Data by Name
7.8.1. dbi_result_get_fields
7.8.2. dbi_result_bind_fields
7.8.3. dbi_result_get_char
7.8.4. dbi_result_get_uchar
7.8.5. dbi_result_get_short
7.8.6. dbi_result_get_ushort
7.8.7. dbi_result_get_int
7.8.8. dbi_result_get_uint
7.8.9. dbi_result_get_long
7.8.10. dbi_result_get_ulong
7.8.11. dbi_result_get_longlong
7.8.12. dbi_result_get_ulonglong
7.8.13. dbi_result_get_float
7.8.14. dbi_result_get_double
7.8.15. dbi_result_get_string
7.8.16. dbi_result_get_string_copy
7.8.17. dbi_result_get_binary
7.8.18. dbi_result_get_binary_copy
7.8.19. dbi_result_get_datetime
7.8.20. dbi_result_get_as_longlong
7.8.21. dbi_result_get_as_string_copy
7.8.22. dbi_result_bind_char
7.8.23. dbi_result_bind_uchar
7.8.24. dbi_result_bind_short
7.8.25. dbi_result_bind_ushort
7.8.26. dbi_result_bind_int
7.8.27. dbi_result_bind_uint
7.8.28. dbi_result_bind_long
7.8.29. dbi_result_bind_ulong
7.8.30. dbi_result_bind_longlong
7.8.31. dbi_result_bind_ulonglong
7.8.32. dbi_result_bind_float
7.8.33. dbi_result_bind_double
7.8.34. dbi_result_bind_string
7.8.35. dbi_result_bind_binary
7.8.36. dbi_result_bind_string_copy
7.8.37. dbi_result_bind_binary_copy
7.8.38. dbi_result_bind_datetime
7.9. Retrieving Field Data by Index
7.9.1. dbi_result_get_char_idx
7.9.2. dbi_result_get_uchar_idx
7.9.3. dbi_result_get_short_idx
7.9.4. dbi_result_get_ushort_idx
7.9.5. dbi_result_get_int_idx
7.9.6. dbi_result_get_uint_idx
7.9.7. dbi_result_get_long_idx
7.9.8. dbi_result_get_ulong_idx
7.9.9. dbi_result_get_longlong_idx
7.9.10. dbi_result_get_ulonglong_idx
7.9.11. dbi_result_get_float_idx
7.9.12. dbi_result_get_double_idx
7.9.13. dbi_result_get_string_idx
7.9.14. dbi_result_get_string_copy_idx
7.9.15. dbi_result_get_binary_idx
7.9.16. dbi_result_get_binary_copy_idx
7.9.17. dbi_result_get_datetime_idx
7.9.18. dbi_result_get_as_longlong_idx
7.9.19. dbi_result_get_as_string_copy_idx
A. GNU Free Documentation License
List of Tables
3-1. get* and bind* functions sorted by field type
4-1. libdbi error numbers