module.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* module.h - definitions for the module
  2. *
  3. * Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
  4. *
  5. * This file is part of pysqlite.
  6. *
  7. * This software is provided 'as-is', without any express or implied
  8. * warranty. In no event will the authors be held liable for any damages
  9. * arising from the use of this software.
  10. *
  11. * Permission is granted to anyone to use this software for any purpose,
  12. * including commercial applications, and to alter it and redistribute it
  13. * freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not
  16. * claim that you wrote the original software. If you use this software
  17. * in a product, an acknowledgment in the product documentation would be
  18. * appreciated but is not required.
  19. * 2. Altered source versions must be plainly marked as such, and must not be
  20. * misrepresented as being the original software.
  21. * 3. This notice may not be removed or altered from any source distribution.
  22. */
  23. #ifndef PYSQLITE_MODULE_H
  24. #define PYSQLITE_MODULE_H
  25. #define PY_SSIZE_T_CLEAN
  26. #include "Python.h"
  27. #define LEGACY_TRANSACTION_CONTROL -1
  28. #define PYSQLITE_VERSION "2.6.0"
  29. #define MODULE_NAME "sqlite3"
  30. typedef struct {
  31. PyObject *DataError;
  32. PyObject *DatabaseError;
  33. PyObject *Error;
  34. PyObject *IntegrityError;
  35. PyObject *InterfaceError;
  36. PyObject *InternalError;
  37. PyObject *NotSupportedError;
  38. PyObject *OperationalError;
  39. PyObject *ProgrammingError;
  40. PyObject *Warning;
  41. /* A dictionary, mapping column types (INTEGER, VARCHAR, etc.) to converter
  42. * functions, that convert the SQL value to the appropriate Python value.
  43. * The key is uppercase.
  44. */
  45. PyObject *converters;
  46. PyObject *lru_cache;
  47. PyObject *psyco_adapters; // The adapters registry
  48. int BaseTypeAdapted;
  49. int enable_callback_tracebacks;
  50. PyTypeObject *BlobType;
  51. PyTypeObject *ConnectionType;
  52. PyTypeObject *CursorType;
  53. PyTypeObject *PrepareProtocolType;
  54. PyTypeObject *RowType;
  55. PyTypeObject *StatementType;
  56. /* Pointers to interned strings */
  57. PyObject *str___adapt__;
  58. PyObject *str___conform__;
  59. PyObject *str_executescript;
  60. PyObject *str_finalize;
  61. PyObject *str_inverse;
  62. PyObject *str_step;
  63. PyObject *str_upper;
  64. PyObject *str_value;
  65. } pysqlite_state;
  66. extern pysqlite_state pysqlite_global_state;
  67. static inline pysqlite_state *
  68. pysqlite_get_state(PyObject *module)
  69. {
  70. pysqlite_state *state = (pysqlite_state *)PyModule_GetState(module);
  71. assert(state != NULL);
  72. return state;
  73. }
  74. extern struct PyModuleDef _sqlite3module;
  75. static inline pysqlite_state *
  76. pysqlite_get_state_by_type(PyTypeObject *tp)
  77. {
  78. PyObject *module = PyType_GetModuleByDef(tp, &_sqlite3module);
  79. assert(module != NULL);
  80. return pysqlite_get_state(module);
  81. }
  82. extern const char *pysqlite_error_name(int rc);
  83. #define PARSE_DECLTYPES 1
  84. #define PARSE_COLNAMES 2
  85. #endif