psycopg-yugabytedb 3.3.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. psycopg_yugabytedb-3.3.4.1/LICENSE.txt +165 -0
  2. psycopg_yugabytedb-3.3.4.1/PKG-INFO +232 -0
  3. psycopg_yugabytedb-3.3.4.1/README.rst +166 -0
  4. psycopg_yugabytedb-3.3.4.1/psycopg/__init__.py +116 -0
  5. psycopg_yugabytedb-3.3.4.1/psycopg/_acompat.py +92 -0
  6. psycopg_yugabytedb-3.3.4.1/psycopg/_adapters_map.py +301 -0
  7. psycopg_yugabytedb-3.3.4.1/psycopg/_capabilities.py +150 -0
  8. psycopg_yugabytedb-3.3.4.1/psycopg/_cmodule.py +36 -0
  9. psycopg_yugabytedb-3.3.4.1/psycopg/_column.py +101 -0
  10. psycopg_yugabytedb-3.3.4.1/psycopg/_compat.py +63 -0
  11. psycopg_yugabytedb-3.3.4.1/psycopg/_connection_base.py +699 -0
  12. psycopg_yugabytedb-3.3.4.1/psycopg/_connection_info.py +201 -0
  13. psycopg_yugabytedb-3.3.4.1/psycopg/_conninfo_attempts.py +106 -0
  14. psycopg_yugabytedb-3.3.4.1/psycopg/_conninfo_attempts_async.py +110 -0
  15. psycopg_yugabytedb-3.3.4.1/psycopg/_conninfo_utils.py +127 -0
  16. psycopg_yugabytedb-3.3.4.1/psycopg/_copy.py +288 -0
  17. psycopg_yugabytedb-3.3.4.1/psycopg/_copy_async.py +289 -0
  18. psycopg_yugabytedb-3.3.4.1/psycopg/_copy_base.py +423 -0
  19. psycopg_yugabytedb-3.3.4.1/psycopg/_cursor_base.py +668 -0
  20. psycopg_yugabytedb-3.3.4.1/psycopg/_dns.py +241 -0
  21. psycopg_yugabytedb-3.3.4.1/psycopg/_encodings.py +153 -0
  22. psycopg_yugabytedb-3.3.4.1/psycopg/_enums.py +80 -0
  23. psycopg_yugabytedb-3.3.4.1/psycopg/_oids.py +97 -0
  24. psycopg_yugabytedb-3.3.4.1/psycopg/_pipeline.py +81 -0
  25. psycopg_yugabytedb-3.3.4.1/psycopg/_pipeline_async.py +77 -0
  26. psycopg_yugabytedb-3.3.4.1/psycopg/_pipeline_base.py +181 -0
  27. psycopg_yugabytedb-3.3.4.1/psycopg/_preparing.py +193 -0
  28. psycopg_yugabytedb-3.3.4.1/psycopg/_py_transformer.py +357 -0
  29. psycopg_yugabytedb-3.3.4.1/psycopg/_queries.py +482 -0
  30. psycopg_yugabytedb-3.3.4.1/psycopg/_server_cursor.py +160 -0
  31. psycopg_yugabytedb-3.3.4.1/psycopg/_server_cursor_async.py +158 -0
  32. psycopg_yugabytedb-3.3.4.1/psycopg/_server_cursor_base.py +217 -0
  33. psycopg_yugabytedb-3.3.4.1/psycopg/_struct.py +57 -0
  34. psycopg_yugabytedb-3.3.4.1/psycopg/_tpc.py +114 -0
  35. psycopg_yugabytedb-3.3.4.1/psycopg/_transformer.py +21 -0
  36. psycopg_yugabytedb-3.3.4.1/psycopg/_tstrings.py +164 -0
  37. psycopg_yugabytedb-3.3.4.1/psycopg/_typeinfo.py +339 -0
  38. psycopg_yugabytedb-3.3.4.1/psycopg/_typemod.py +86 -0
  39. psycopg_yugabytedb-3.3.4.1/psycopg/_tz.py +45 -0
  40. psycopg_yugabytedb-3.3.4.1/psycopg/_wrappers.py +137 -0
  41. psycopg_yugabytedb-3.3.4.1/psycopg/abc.py +249 -0
  42. psycopg_yugabytedb-3.3.4.1/psycopg/adapt.py +152 -0
  43. psycopg_yugabytedb-3.3.4.1/psycopg/client_cursor.py +93 -0
  44. psycopg_yugabytedb-3.3.4.1/psycopg/connection.py +716 -0
  45. psycopg_yugabytedb-3.3.4.1/psycopg/connection_async.py +771 -0
  46. psycopg_yugabytedb-3.3.4.1/psycopg/conninfo.py +151 -0
  47. psycopg_yugabytedb-3.3.4.1/psycopg/copy.py +35 -0
  48. psycopg_yugabytedb-3.3.4.1/psycopg/crdb/__init__.py +20 -0
  49. psycopg_yugabytedb-3.3.4.1/psycopg/crdb/_types.py +200 -0
  50. psycopg_yugabytedb-3.3.4.1/psycopg/crdb/connection.py +102 -0
  51. psycopg_yugabytedb-3.3.4.1/psycopg/cursor.py +343 -0
  52. psycopg_yugabytedb-3.3.4.1/psycopg/cursor_async.py +345 -0
  53. psycopg_yugabytedb-3.3.4.1/psycopg/dbapi20.py +129 -0
  54. psycopg_yugabytedb-3.3.4.1/psycopg/errors.py +1774 -0
  55. psycopg_yugabytedb-3.3.4.1/psycopg/generators.py +397 -0
  56. psycopg_yugabytedb-3.3.4.1/psycopg/postgres.py +158 -0
  57. psycopg_yugabytedb-3.3.4.1/psycopg/pq/__init__.py +134 -0
  58. psycopg_yugabytedb-3.3.4.1/psycopg/pq/_debug.py +108 -0
  59. psycopg_yugabytedb-3.3.4.1/psycopg/pq/_enums.py +259 -0
  60. psycopg_yugabytedb-3.3.4.1/psycopg/pq/_pq_ctypes.py +844 -0
  61. psycopg_yugabytedb-3.3.4.1/psycopg/pq/_pq_ctypes.pyi +229 -0
  62. psycopg_yugabytedb-3.3.4.1/psycopg/pq/abc.py +345 -0
  63. psycopg_yugabytedb-3.3.4.1/psycopg/pq/misc.py +198 -0
  64. psycopg_yugabytedb-3.3.4.1/psycopg/pq/pq_ctypes.py +1265 -0
  65. psycopg_yugabytedb-3.3.4.1/psycopg/py.typed +0 -0
  66. psycopg_yugabytedb-3.3.4.1/psycopg/raw_cursor.py +46 -0
  67. psycopg_yugabytedb-3.3.4.1/psycopg/rows.py +264 -0
  68. psycopg_yugabytedb-3.3.4.1/psycopg/sql.py +553 -0
  69. psycopg_yugabytedb-3.3.4.1/psycopg/transaction.py +308 -0
  70. psycopg_yugabytedb-3.3.4.1/psycopg/types/__init__.py +11 -0
  71. psycopg_yugabytedb-3.3.4.1/psycopg/types/array.py +463 -0
  72. psycopg_yugabytedb-3.3.4.1/psycopg/types/bool.py +50 -0
  73. psycopg_yugabytedb-3.3.4.1/psycopg/types/composite.py +550 -0
  74. psycopg_yugabytedb-3.3.4.1/psycopg/types/datetime.py +740 -0
  75. psycopg_yugabytedb-3.3.4.1/psycopg/types/enum.py +257 -0
  76. psycopg_yugabytedb-3.3.4.1/psycopg/types/hstore.py +244 -0
  77. psycopg_yugabytedb-3.3.4.1/psycopg/types/json.py +315 -0
  78. psycopg_yugabytedb-3.3.4.1/psycopg/types/multirange.py +554 -0
  79. psycopg_yugabytedb-3.3.4.1/psycopg/types/net.py +202 -0
  80. psycopg_yugabytedb-3.3.4.1/psycopg/types/none.py +27 -0
  81. psycopg_yugabytedb-3.3.4.1/psycopg/types/numeric.py +544 -0
  82. psycopg_yugabytedb-3.3.4.1/psycopg/types/numpy.py +98 -0
  83. psycopg_yugabytedb-3.3.4.1/psycopg/types/range.py +733 -0
  84. psycopg_yugabytedb-3.3.4.1/psycopg/types/shapely.py +95 -0
  85. psycopg_yugabytedb-3.3.4.1/psycopg/types/string.py +232 -0
  86. psycopg_yugabytedb-3.3.4.1/psycopg/types/uuid.py +61 -0
  87. psycopg_yugabytedb-3.3.4.1/psycopg/version.py +13 -0
  88. psycopg_yugabytedb-3.3.4.1/psycopg/waiting.py +462 -0
  89. psycopg_yugabytedb-3.3.4.1/psycopg/yb/__init__.py +67 -0
  90. psycopg_yugabytedb-3.3.4.1/psycopg/yb/discovery.py +115 -0
  91. psycopg_yugabytedb-3.3.4.1/psycopg/yb/node.py +58 -0
  92. psycopg_yugabytedb-3.3.4.1/psycopg/yb/params.py +188 -0
  93. psycopg_yugabytedb-3.3.4.1/psycopg/yb/policy/__init__.py +31 -0
  94. psycopg_yugabytedb-3.3.4.1/psycopg/yb/policy/base.py +50 -0
  95. psycopg_yugabytedb-3.3.4.1/psycopg/yb/policy/cluster_aware.py +96 -0
  96. psycopg_yugabytedb-3.3.4.1/psycopg/yb/policy/topology_aware.py +40 -0
  97. psycopg_yugabytedb-3.3.4.1/psycopg/yb/registry.py +664 -0
  98. psycopg_yugabytedb-3.3.4.1/psycopg_yugabytedb.egg-info/PKG-INFO +232 -0
  99. psycopg_yugabytedb-3.3.4.1/psycopg_yugabytedb.egg-info/SOURCES.txt +103 -0
  100. psycopg_yugabytedb-3.3.4.1/psycopg_yugabytedb.egg-info/dependency_links.txt +1 -0
  101. psycopg_yugabytedb-3.3.4.1/psycopg_yugabytedb.egg-info/not-zip-safe +1 -0
  102. psycopg_yugabytedb-3.3.4.1/psycopg_yugabytedb.egg-info/requires.txt +50 -0
  103. psycopg_yugabytedb-3.3.4.1/psycopg_yugabytedb.egg-info/top_level.txt +1 -0
  104. psycopg_yugabytedb-3.3.4.1/pyproject.toml +118 -0
  105. psycopg_yugabytedb-3.3.4.1/setup.cfg +4 -0
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: psycopg-yugabytedb
3
+ Version: 3.3.4.1
4
+ Summary: YugabyteDB smart-driver fork of psycopg 3 — adds cluster-aware and topology-aware load balancing
5
+ Author-email: Daniele Varrazzo <daniele.varrazzo@gmail.com>, Yugabyte <support@yugabyte.com>
6
+ License-Expression: LGPL-3.0-only
7
+ Project-URL: Homepage, https://www.yugabyte.com/
8
+ Project-URL: Documentation, https://docs.yugabyte.com/preview/drivers-orms/python/
9
+ Project-URL: Upstream psycopg, https://psycopg.org/
10
+ Project-URL: Code, https://github.com/yugabyte/psycopg-yugabytedb
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: MacOS :: MacOS X
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: Implementation :: CPython
23
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Database :: Front-Ends
26
+ Classifier: Topic :: Software Development
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Requires-Python: >=3.10
29
+ Description-Content-Type: text/x-rst
30
+ License-File: LICENSE.txt
31
+ Requires-Dist: typing-extensions>=4.6; python_version < "3.13"
32
+ Requires-Dist: tzdata; sys_platform == "win32"
33
+ Provides-Extra: c
34
+ Requires-Dist: psycopg-yugabytedb-c==3.3.4.1; implementation_name != "pypy" and extra == "c"
35
+ Provides-Extra: binary
36
+ Requires-Dist: psycopg-yugabytedb-binary==3.3.4.1; implementation_name != "pypy" and extra == "binary"
37
+ Provides-Extra: pool
38
+ Requires-Dist: psycopg-pool; extra == "pool"
39
+ Provides-Extra: test
40
+ Requires-Dist: anyio>=4.0; extra == "test"
41
+ Requires-Dist: mypy>=1.19.0; implementation_name != "pypy" and extra == "test"
42
+ Requires-Dist: pproxy>=2.7; extra == "test"
43
+ Requires-Dist: pytest>=6.2.5; extra == "test"
44
+ Requires-Dist: pytest-cov>=3.0; extra == "test"
45
+ Requires-Dist: pytest-randomly>=3.5; extra == "test"
46
+ Provides-Extra: dev
47
+ Requires-Dist: ast-comments>=1.1.2; extra == "dev"
48
+ Requires-Dist: black>=26.1.0; extra == "dev"
49
+ Requires-Dist: codespell>=2.2; extra == "dev"
50
+ Requires-Dist: cython-lint>=0.16; extra == "dev"
51
+ Requires-Dist: dnspython>=2.1; extra == "dev"
52
+ Requires-Dist: flake8>=4.0; extra == "dev"
53
+ Requires-Dist: isort[colors]>=6.0; extra == "dev"
54
+ Requires-Dist: isort-psycopg; extra == "dev"
55
+ Requires-Dist: mypy>=1.19.0; extra == "dev"
56
+ Requires-Dist: pre-commit>=4.0.1; extra == "dev"
57
+ Requires-Dist: types-setuptools>=57.4; extra == "dev"
58
+ Requires-Dist: types-shapely>=2.0; extra == "dev"
59
+ Requires-Dist: wheel>=0.37; extra == "dev"
60
+ Provides-Extra: docs
61
+ Requires-Dist: Sphinx>=9.1; extra == "docs"
62
+ Requires-Dist: furo==2025.12.19; extra == "docs"
63
+ Requires-Dist: sphinx-autobuild>=2025.8.25; extra == "docs"
64
+ Requires-Dist: sphinx-autodoc-typehints>=3.10.2; extra == "docs"
65
+ Dynamic: license-file
66
+
67
+ YugabyteDB Psycopg 3: Database adapter for Python
68
+ =================================================
69
+
70
+ Psycopg 3 is a modern implementation of a PostgreSQL adapter for Python.
71
+ This is the YugabyteDB smart-driver fork, distributed as ``psycopg-yugabytedb``.
72
+
73
+ This distribution contains the pure Python package ``psycopg``.
74
+
75
+ .. Note::
76
+
77
+ Despite the lack of number in the package name, this package is the
78
+ successor of psycopg2_.
79
+
80
+ Please use the psycopg2 package if you are maintaining an existing program
81
+ using psycopg2 as a dependency. If you are developing something new,
82
+ Psycopg 3 is the most current implementation of the adapter.
83
+
84
+ .. _psycopg2: https://pypi.org/project/psycopg2/
85
+
86
+
87
+ YugabyteDB smart driver
88
+ -----------------------
89
+
90
+ This fork (distribution name ``psycopg-yugabytedb``) extends psycopg 3 with
91
+ cluster-aware and topology-aware connection load balancing for `YugabyteDB`_.
92
+ The import name stays ``psycopg`` — existing code is unchanged. Adding
93
+ ``load_balance_hosts=true`` to the conninfo string opts into the smart driver.
94
+
95
+ .. _YugabyteDB: https://www.yugabyte.com/
96
+
97
+ Opt in with one parameter:
98
+
99
+ .. code-block:: python
100
+
101
+ import psycopg
102
+
103
+ conn = psycopg.connect(
104
+ "host=h1,h2,h3 port=5433 user=yugabyte dbname=yugabyte "
105
+ "load_balance_hosts=true"
106
+ )
107
+
108
+ The driver discovers every live tserver via ``yb_servers()`` on the first
109
+ connect, then distributes subsequent connects across them with a least-loaded
110
+ picker (random tie-break, atomic under a per-cluster lock). One contact point
111
+ in ``host=…`` is enough to bootstrap; the rest of the cluster is discovered.
112
+
113
+ Smart-driver conninfo parameters:
114
+
115
+ .. list-table::
116
+ :header-rows: 1
117
+ :widths: 30 14 12 44
118
+
119
+ * - Parameter
120
+ - Values
121
+ - Default
122
+ - Description
123
+ * - ``load_balance_hosts``
124
+ - ``true`` / ``false`` /
125
+ ``disable`` / ``random``
126
+ - absent
127
+ - ``true`` enables the smart driver. ``false`` is equivalent to libpq's
128
+ ``disable``. ``disable`` / ``random`` pass through to libpq unchanged.
129
+ * - ``topology_keys``
130
+ - ``cloud.region.zone``
131
+ (comma-separated for
132
+ multiple keys)
133
+ - none
134
+ - Restrict picks to tservers matching at least one placement. Zone may
135
+ be ``*`` for any zone in that cloud/region. Cloud / region wildcards
136
+ are rejected. Strict in v1 — no cluster-wide fallback if all
137
+ matching nodes are down.
138
+ * - ``yb_servers_refresh_interval``
139
+ - seconds (integer)
140
+ - ``300``
141
+ - How often to re-query ``yb_servers()``. Clamped to ``[0, 600]``.
142
+ * - ``failed_host_reconnect_delay_secs``
143
+ - seconds (integer)
144
+ - ``5``
145
+ - How long to quarantine a node after a failed connect, before
146
+ reconsidering it. Clamped to ``[0, 60]``.
147
+
148
+ Topology-aware example — bind traffic to one zone:
149
+
150
+ .. code-block:: python
151
+
152
+ conn = psycopg.connect(
153
+ "host=h1,h2,h3 port=5433 user=yugabyte dbname=yugabyte "
154
+ "load_balance_hosts=true "
155
+ "topology_keys=cloud1.datacenter1.zoneA"
156
+ )
157
+
158
+ The upstream ``psycopg-pool`` connection pool works unchanged with the smart
159
+ driver — the dispatcher sits underneath the pool, so pool-managed connections
160
+ honour the configured policy too. Install it via the ``[pool]`` extra:
161
+
162
+ .. code-block:: bash
163
+
164
+ pip install "psycopg-yugabytedb[pool]"
165
+
166
+ That pulls our driver plus the unmodified upstream ``psycopg-pool``; the
167
+ pool's ``import psycopg`` resolves to our driver and every conn the pool
168
+ opens goes through the dispatcher.
169
+
170
+ Install without the ``[pool]`` extra with ``pip install psycopg-yugabytedb``,
171
+ or pin to a specific version (``3.3.4.1`` is the first GA release). The fork
172
+ cannot coexist with upstream ``psycopg`` in the same environment — both
173
+ install into ``site-packages/psycopg/``.
174
+
175
+ Logging
176
+ ~~~~~~~
177
+
178
+ Every smart-driver module logs to its own logger under ``psycopg.yb.*``.
179
+ Levels follow the standard library, plus a custom ``TRACE`` level (numeric
180
+ 5, finer than ``DEBUG``) for counter-mutation-level firehose detail.
181
+
182
+ * ``WARNING`` — driver gave up (no eligible nodes, control conn re-open failed)
183
+ * ``INFO`` — cluster bootstrap, topology change observed, host quarantined,
184
+ control conn re-opened on a survivor
185
+ * ``DEBUG`` — per-pick, per-refresh, per-control-conn open/close
186
+ * ``TRACE`` — every counter increment / decrement, every filtered candidate
187
+
188
+ Enable:
189
+
190
+ .. code-block:: python
191
+
192
+ import logging
193
+ from psycopg.yb import TRACE
194
+
195
+ logging.basicConfig(level=logging.INFO)
196
+
197
+ # Lifecycle events only (default INFO above is fine):
198
+ logging.getLogger("psycopg.yb").setLevel(logging.INFO)
199
+
200
+ # Per-operation debug:
201
+ logging.getLogger("psycopg.yb").setLevel(logging.DEBUG)
202
+
203
+ # Full firehose:
204
+ logging.getLogger("psycopg.yb").setLevel(TRACE)
205
+
206
+ # Or narrow to one subsystem:
207
+ logging.getLogger("psycopg.yb.policy").setLevel(logging.DEBUG)
208
+
209
+
210
+ Installation
211
+ ------------
212
+
213
+ In short, run the following::
214
+
215
+ pip install --upgrade pip # to upgrade pip
216
+ pip install "psycopg[binary,pool]" # to install package and dependencies
217
+
218
+ If something goes wrong, and for more information about installation, please
219
+ check out the `Installation documentation`__.
220
+
221
+ .. __: https://www.psycopg.org/psycopg3/docs/basic/install.html#
222
+
223
+
224
+ Hacking
225
+ -------
226
+
227
+ For development information check out `the project readme`__.
228
+
229
+ .. __: https://github.com/psycopg/psycopg#readme
230
+
231
+
232
+ Copyright (C) 2020 The Psycopg Team
@@ -0,0 +1,166 @@
1
+ YugabyteDB Psycopg 3: Database adapter for Python
2
+ =================================================
3
+
4
+ Psycopg 3 is a modern implementation of a PostgreSQL adapter for Python.
5
+ This is the YugabyteDB smart-driver fork, distributed as ``psycopg-yugabytedb``.
6
+
7
+ This distribution contains the pure Python package ``psycopg``.
8
+
9
+ .. Note::
10
+
11
+ Despite the lack of number in the package name, this package is the
12
+ successor of psycopg2_.
13
+
14
+ Please use the psycopg2 package if you are maintaining an existing program
15
+ using psycopg2 as a dependency. If you are developing something new,
16
+ Psycopg 3 is the most current implementation of the adapter.
17
+
18
+ .. _psycopg2: https://pypi.org/project/psycopg2/
19
+
20
+
21
+ YugabyteDB smart driver
22
+ -----------------------
23
+
24
+ This fork (distribution name ``psycopg-yugabytedb``) extends psycopg 3 with
25
+ cluster-aware and topology-aware connection load balancing for `YugabyteDB`_.
26
+ The import name stays ``psycopg`` — existing code is unchanged. Adding
27
+ ``load_balance_hosts=true`` to the conninfo string opts into the smart driver.
28
+
29
+ .. _YugabyteDB: https://www.yugabyte.com/
30
+
31
+ Opt in with one parameter:
32
+
33
+ .. code-block:: python
34
+
35
+ import psycopg
36
+
37
+ conn = psycopg.connect(
38
+ "host=h1,h2,h3 port=5433 user=yugabyte dbname=yugabyte "
39
+ "load_balance_hosts=true"
40
+ )
41
+
42
+ The driver discovers every live tserver via ``yb_servers()`` on the first
43
+ connect, then distributes subsequent connects across them with a least-loaded
44
+ picker (random tie-break, atomic under a per-cluster lock). One contact point
45
+ in ``host=…`` is enough to bootstrap; the rest of the cluster is discovered.
46
+
47
+ Smart-driver conninfo parameters:
48
+
49
+ .. list-table::
50
+ :header-rows: 1
51
+ :widths: 30 14 12 44
52
+
53
+ * - Parameter
54
+ - Values
55
+ - Default
56
+ - Description
57
+ * - ``load_balance_hosts``
58
+ - ``true`` / ``false`` /
59
+ ``disable`` / ``random``
60
+ - absent
61
+ - ``true`` enables the smart driver. ``false`` is equivalent to libpq's
62
+ ``disable``. ``disable`` / ``random`` pass through to libpq unchanged.
63
+ * - ``topology_keys``
64
+ - ``cloud.region.zone``
65
+ (comma-separated for
66
+ multiple keys)
67
+ - none
68
+ - Restrict picks to tservers matching at least one placement. Zone may
69
+ be ``*`` for any zone in that cloud/region. Cloud / region wildcards
70
+ are rejected. Strict in v1 — no cluster-wide fallback if all
71
+ matching nodes are down.
72
+ * - ``yb_servers_refresh_interval``
73
+ - seconds (integer)
74
+ - ``300``
75
+ - How often to re-query ``yb_servers()``. Clamped to ``[0, 600]``.
76
+ * - ``failed_host_reconnect_delay_secs``
77
+ - seconds (integer)
78
+ - ``5``
79
+ - How long to quarantine a node after a failed connect, before
80
+ reconsidering it. Clamped to ``[0, 60]``.
81
+
82
+ Topology-aware example — bind traffic to one zone:
83
+
84
+ .. code-block:: python
85
+
86
+ conn = psycopg.connect(
87
+ "host=h1,h2,h3 port=5433 user=yugabyte dbname=yugabyte "
88
+ "load_balance_hosts=true "
89
+ "topology_keys=cloud1.datacenter1.zoneA"
90
+ )
91
+
92
+ The upstream ``psycopg-pool`` connection pool works unchanged with the smart
93
+ driver — the dispatcher sits underneath the pool, so pool-managed connections
94
+ honour the configured policy too. Install it via the ``[pool]`` extra:
95
+
96
+ .. code-block:: bash
97
+
98
+ pip install "psycopg-yugabytedb[pool]"
99
+
100
+ That pulls our driver plus the unmodified upstream ``psycopg-pool``; the
101
+ pool's ``import psycopg`` resolves to our driver and every conn the pool
102
+ opens goes through the dispatcher.
103
+
104
+ Install without the ``[pool]`` extra with ``pip install psycopg-yugabytedb``,
105
+ or pin to a specific version (``3.3.4.1`` is the first GA release). The fork
106
+ cannot coexist with upstream ``psycopg`` in the same environment — both
107
+ install into ``site-packages/psycopg/``.
108
+
109
+ Logging
110
+ ~~~~~~~
111
+
112
+ Every smart-driver module logs to its own logger under ``psycopg.yb.*``.
113
+ Levels follow the standard library, plus a custom ``TRACE`` level (numeric
114
+ 5, finer than ``DEBUG``) for counter-mutation-level firehose detail.
115
+
116
+ * ``WARNING`` — driver gave up (no eligible nodes, control conn re-open failed)
117
+ * ``INFO`` — cluster bootstrap, topology change observed, host quarantined,
118
+ control conn re-opened on a survivor
119
+ * ``DEBUG`` — per-pick, per-refresh, per-control-conn open/close
120
+ * ``TRACE`` — every counter increment / decrement, every filtered candidate
121
+
122
+ Enable:
123
+
124
+ .. code-block:: python
125
+
126
+ import logging
127
+ from psycopg.yb import TRACE
128
+
129
+ logging.basicConfig(level=logging.INFO)
130
+
131
+ # Lifecycle events only (default INFO above is fine):
132
+ logging.getLogger("psycopg.yb").setLevel(logging.INFO)
133
+
134
+ # Per-operation debug:
135
+ logging.getLogger("psycopg.yb").setLevel(logging.DEBUG)
136
+
137
+ # Full firehose:
138
+ logging.getLogger("psycopg.yb").setLevel(TRACE)
139
+
140
+ # Or narrow to one subsystem:
141
+ logging.getLogger("psycopg.yb.policy").setLevel(logging.DEBUG)
142
+
143
+
144
+ Installation
145
+ ------------
146
+
147
+ In short, run the following::
148
+
149
+ pip install --upgrade pip # to upgrade pip
150
+ pip install "psycopg[binary,pool]" # to install package and dependencies
151
+
152
+ If something goes wrong, and for more information about installation, please
153
+ check out the `Installation documentation`__.
154
+
155
+ .. __: https://www.psycopg.org/psycopg3/docs/basic/install.html#
156
+
157
+
158
+ Hacking
159
+ -------
160
+
161
+ For development information check out `the project readme`__.
162
+
163
+ .. __: https://github.com/psycopg/psycopg#readme
164
+
165
+
166
+ Copyright (C) 2020 The Psycopg Team
@@ -0,0 +1,116 @@
1
+ """
2
+ psycopg -- PostgreSQL database adapter for Python
3
+ """
4
+
5
+ # Copyright (C) 2020 The Psycopg Team
6
+
7
+ import logging
8
+
9
+ from . import pq # noqa: F401 import early to stabilize side effects
10
+ from . import dbapi20, postgres, types
11
+ from ._tpc import Xid
12
+ from .copy import AsyncCopy, Copy
13
+ from ._enums import IsolationLevel
14
+ from .cursor import Cursor
15
+ from .errors import DatabaseError, DataError, Error, IntegrityError, InterfaceError
16
+ from .errors import InternalError, NotSupportedError, OperationalError
17
+ from .errors import ProgrammingError, Warning
18
+ from ._column import Column
19
+ from .dbapi20 import BINARY, DATETIME, NUMBER, ROWID, STRING, Binary, Date
20
+ from .dbapi20 import DateFromTicks, Time, TimeFromTicks, Timestamp, TimestampFromTicks
21
+ from .version import __version__ as __version__ # noqa: F401
22
+ from ._pipeline import Pipeline
23
+ from .connection import Connection
24
+ from .raw_cursor import AsyncRawCursor, AsyncRawServerCursor, RawCursor, RawServerCursor
25
+ from .transaction import AsyncTransaction, Rollback, Transaction
26
+ from .cursor_async import AsyncCursor
27
+ from ._capabilities import Capabilities, capabilities
28
+ from .client_cursor import AsyncClientCursor, ClientCursor
29
+ from ._server_cursor import ServerCursor
30
+ from ._pipeline_async import AsyncPipeline
31
+ from ._connection_base import BaseConnection, Notify
32
+ from ._connection_info import ConnectionInfo
33
+ from .connection_async import AsyncConnection
34
+ from ._server_cursor_async import AsyncServerCursor
35
+
36
+ # Set the logger to a quiet default, can be enabled if needed
37
+ if (logger := logging.getLogger("psycopg")).level == logging.NOTSET:
38
+ logger.setLevel(logging.WARNING)
39
+
40
+ # DBAPI compliance
41
+ connect = Connection.connect
42
+ apilevel = "2.0"
43
+ threadsafety = 2
44
+ paramstyle = "pyformat"
45
+
46
+ # register default adapters for PostgreSQL
47
+ adapters = postgres.adapters # exposed by the package
48
+ postgres.register_default_types(adapters.types)
49
+ postgres.register_default_adapters(adapters)
50
+
51
+ # After the default ones, because these can deal with the bytea oid better
52
+ dbapi20.register_dbapi20_adapters(adapters)
53
+
54
+ # Must come after all the types have been registered
55
+ types.array.register_all_arrays(adapters)
56
+
57
+ # Note: defining the exported methods helps both Sphynx in documenting that
58
+ # this is the canonical place to obtain them and should be used by MyPy too,
59
+ # so that function signatures are consistent with the documentation.
60
+ __all__ = [
61
+ "AsyncClientCursor",
62
+ "AsyncConnection",
63
+ "AsyncCopy",
64
+ "AsyncCursor",
65
+ "AsyncPipeline",
66
+ "AsyncRawCursor",
67
+ "AsyncRawServerCursor",
68
+ "AsyncServerCursor",
69
+ "AsyncTransaction",
70
+ "BaseConnection",
71
+ "Capabilities",
72
+ "capabilities",
73
+ "ClientCursor",
74
+ "Column",
75
+ "Connection",
76
+ "ConnectionInfo",
77
+ "Copy",
78
+ "Cursor",
79
+ "IsolationLevel",
80
+ "Notify",
81
+ "Pipeline",
82
+ "RawCursor",
83
+ "RawServerCursor",
84
+ "Rollback",
85
+ "ServerCursor",
86
+ "Transaction",
87
+ "Xid",
88
+ # DBAPI exports
89
+ "connect",
90
+ "apilevel",
91
+ "threadsafety",
92
+ "paramstyle",
93
+ "Warning",
94
+ "Error",
95
+ "InterfaceError",
96
+ "DatabaseError",
97
+ "DataError",
98
+ "OperationalError",
99
+ "IntegrityError",
100
+ "InternalError",
101
+ "ProgrammingError",
102
+ "NotSupportedError",
103
+ # DBAPI type constructors and singletons
104
+ "Binary",
105
+ "Date",
106
+ "DateFromTicks",
107
+ "Time",
108
+ "TimeFromTicks",
109
+ "Timestamp",
110
+ "TimestampFromTicks",
111
+ "BINARY",
112
+ "DATETIME",
113
+ "NUMBER",
114
+ "ROWID",
115
+ "STRING",
116
+ ]