gbase8sdb 0.2.1__cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

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.
gbase8sdb/errors.py ADDED
@@ -0,0 +1,303 @@
1
+ # coding: utf-8
2
+
3
+ import re
4
+ from . import exceptions
5
+
6
+ ERR_EXCEPTION_TYPES = {
7
+ 1: exceptions.InterfaceError,
8
+ 2: exceptions.ProgrammingError,
9
+ 3: exceptions.NotSupportedError,
10
+ 4: exceptions.DatabaseError,
11
+ 5: exceptions.InternalError,
12
+ 6: exceptions.OperationalError,
13
+ 7: exceptions.Warning,
14
+ }
15
+
16
+ # dbapi error code in InterfaceError
17
+ ERR_MISSING_ERROR = 1000
18
+ ERR_NOT_CONNECTED = 1001
19
+ ERR_NOT_A_QUERY = 1002
20
+ ERR_CURSOR_NOT_OPEN = 1003
21
+
22
+ # dbapi error code in ProgrammingError
23
+ ERR_NO_STATEMENT = 2001
24
+ ERR_NO_STATEMENT_PREPARED = 2002
25
+ ERR_WRONG_EXECUTE_PARAMETERS_TYPE = 2003
26
+ ERR_WRONG_EXECUTEMANY_PARAMETERS_TYPE = 2004
27
+ ERR_ARGS_AND_KEYWORD_ARGS = 2005
28
+ ERR_MIXED_POSITIONAL_AND_NAMED_BINDS = 2006
29
+ ERR_EXPECTING_TYPE = 2007
30
+ ERR_MIXED_ELEMENT_TYPES = 2008
31
+ ERR_WRONG_ARRAY_DEFINITION = 2009
32
+ ERR_ARGS_MUST_BE_LIST_OR_TUPLE = 2010
33
+ ERR_KEYWORD_ARGS_MUST_BE_DICT = 2011
34
+ ERR_DUPLICATED_PARAMETER = 2012
35
+ ERR_EXPECTING_VAR = 2013
36
+ ERR_INCORRECT_VAR_ARRAYSIZE = 2014
37
+ ERR_INVALID_MAKEDSN_ARG = 2015
38
+ ERR_INIT_GBASE8S_CLIENT_NOT_CALLED = 2016
39
+ ERR_INVALID_GCI_ATTR_TYPE = 2017
40
+ ERR_INVALID_CONNECT_PARAMS = 2018
41
+ ERR_EXPECTING_LIST_FOR_ARRAY_VAR = 2019
42
+ ERR_INVALID_LOB_OFFSET = 2020
43
+ ERR_INVALID_ARRAYSIZE = 2021
44
+ ERR_INVALID_LOB_AMOUNT = 2022
45
+ ERR_INVALID_ARGS = 2023
46
+
47
+ # dbapi error code in NotSupportedError
48
+ ERR_TIME_NOT_SUPPORTED = 3000
49
+ ERR_PYTHON_VALUE_NOT_SUPPORTED = 3001
50
+ ERR_PYTHON_TYPE_NOT_SUPPORTED = 3002
51
+ ERR_UNSUPPORTED_TYPE_SET = 3003
52
+ ERR_ARRAYS_OF_ARRAYS = 3004
53
+ ERR_GBASE8S_TYPE_NOT_SUPPORTED = 3005
54
+ ERR_DB_TYPE_NOT_SUPPORTED = 3006
55
+ ERR_SELF_BIND_NOT_SUPPORTED = 3007
56
+ ERR_UNSUPPORTED_PYTHON_TYPE_FOR_DB_TYPE = 3008
57
+ ERR_LOB_OF_WRONG_TYPE = 3009
58
+ ERR_GBASE8S_TYPE_NAME_NOT_SUPPORTED = 3010
59
+ ERR_NAMED_TIMEZONE_NOT_SUPPORTED = 3011
60
+ ERR_CURSOR_DIFF_CONNECTION = 3012
61
+
62
+
63
+ # dbapi error code in DatabaseError
64
+ ERR_GBASE8S_NUMBER_NO_REPR = 4000
65
+ ERR_INVALID_NUMBER = 4001
66
+ ERR_NUMBER_WITH_INVALID_EXPONENT = 4002
67
+ ERR_NUMBER_STRING_OF_ZERO_LENGTH = 4003
68
+ ERR_NUMBER_STRING_TOO_LONG = 4004
69
+ ERR_NUMBER_WITH_EMPTY_EXPONENT = 4005
70
+ ERR_CONTENT_INVALID_AFTER_NUMBER = 4006
71
+
72
+
73
+ # error code in InternalError
74
+ ERR_BUFFER_LENGTH_INSUFFICIENT = 5001
75
+ ERR_INTEGER_TOO_LARGE = 5002
76
+ ERR_UNEXPECTED_NEGATIVE_INTEGER = 5003
77
+ ERR_UNEXPECTED_END_OF_DATA = 5004
78
+
79
+
80
+ class ErrorWrapper:
81
+ regex_server_error = re.compile("ERROR:\s+\-(?P<code>[0-9]+):\s+.*")
82
+ regex_gci_error = re.compile("ERROR:\[GCI\]\s+.*")
83
+
84
+ def __init__(
85
+ self,
86
+ message: str = None,
87
+ context: str = None,
88
+ isrecoverable: bool = False,
89
+ iswarning: bool = False,
90
+ code: int = 0,
91
+ offset: int = 0,
92
+ ) -> None:
93
+ self.exc_type = exceptions.DatabaseError
94
+ self.is_session_dead = False
95
+ self.offset = offset
96
+ self.code = code
97
+ self.full_code = ""
98
+ self.iswarning = iswarning
99
+ self.isrecoverable = isrecoverable
100
+ self.context = context
101
+ self.message = message
102
+ self._wrapper_error()
103
+
104
+ def _wrapper_error(self):
105
+ if self.message is not None:
106
+ if not self.message.startswith("ERROR"): # GDPI ERROR
107
+ pos = self.message.find(":")
108
+ if pos > 0:
109
+ self.full_code = self.message[:pos]
110
+ else:
111
+ match = self.regex_server_error.match(self.message)
112
+ if match is not None: # Gbase8s error
113
+ self.code = int(match.group("code"))
114
+ self.full_code = f"GBA-{self.code}"
115
+ else: # GCI error
116
+ match = self.regex_gci_error.match(self.message)
117
+ if match is not None:
118
+ self.full_code = f"GCI-{self.code}"
119
+
120
+ if self.full_code.startswith("DBAPI-"):
121
+ driver_error_num = int(self.full_code[6:])
122
+ self.exc_type = ERR_EXCEPTION_TYPES[driver_error_num // 1000]
123
+ elif self.full_code.startswith("GCI-"): # GCI error as InterfaceError
124
+ self.exc_type = exceptions.InterfaceError
125
+ elif self.code != 0:
126
+ if self.code in ERR_INTEGRITY_ERROR_CODES:
127
+ self.exc_type = exceptions.IntegrityError
128
+ elif self.code in ERR_PROGRAMMING_ERROR_CODES:
129
+ self.exc_type = exceptions.ProgrammingError
130
+ elif self.code in ERR_DATA_ERROR_CODES:
131
+ self.exc_type = exceptions.DataError
132
+
133
+
134
+ def __str__(self):
135
+ return self.message
136
+
137
+
138
+ # error raise by gbase8sdb
139
+ ERROR_TYPE = "DBAPI"
140
+
141
+ def _get_whole_error(code: int, **kwargs) -> str:
142
+ msg_map = ERROR_MSG_MAPPING.get(code, None)
143
+ if not msg_map:
144
+ msg_map = f"not found error code: {code}."
145
+ kwargs = {}
146
+ code = ERR_MISSING_ERROR
147
+ try:
148
+ whole_msg = msg_map.format(**kwargs)
149
+ except KeyError:
150
+ whole_msg = msg_map + "\nformat error with :\n" + str(kwargs)
151
+ return f"{ERROR_TYPE}-{code:04}: {whole_msg}"
152
+
153
+
154
+ def _create_error_wrapper(code: int, context_error_message: str = None, cause: Exception = None, **args) -> ErrorWrapper:
155
+ message = _get_whole_error(code, **args)
156
+ if context_error_message is None and cause is not None:
157
+ context_error_message = str(cause)
158
+ if context_error_message is not None:
159
+ message = f"{message}\n{context_error_message}"
160
+ return ErrorWrapper(message)
161
+
162
+
163
+ def raise_error(error_num: int, context_error_message: str = None, cause: Exception = None, **args) -> None:
164
+ error = _create_error_wrapper(error_num, context_error_message, cause, **args)
165
+ raise error.exc_type(error) from cause
166
+
167
+
168
+
169
+ # GBA codes in IntegrityError
170
+ ERR_INTEGRITY_ERROR_CODES = [
171
+ 268, # unique constraint violated
172
+ 391, # cannot insert NULL
173
+ 530, # check constraint violated
174
+ 691, # referential constraint
175
+ 703, # Primary key on table has a field with a null key value
176
+ ]
177
+ # GBA codes in ProgrammingError
178
+ ERR_PROGRAMMING_ERROR_CODES = [
179
+ 206, # table not found
180
+ 310, # table already exists
181
+ 201, # syntax error
182
+ ]
183
+
184
+ # GBA codes in DataError
185
+ ERR_DATA_ERROR_CODES = [
186
+ 1202, # divide by zero.
187
+ ]
188
+
189
+
190
+ # mapping error code and error message
191
+ ERROR_MSG_MAPPING = {
192
+ ERR_KEYWORD_ARGS_MUST_BE_DICT: (
193
+ '<keyword_parameters> must be dict'
194
+ ),
195
+ ERR_LOB_OF_WRONG_TYPE: (
196
+ "LOB must be type {expected_type_name}, not type {actual_type_name}"
197
+ ),
198
+ ERR_MIXED_ELEMENT_TYPES: (
199
+ "The element {element} does not match the data type of the preceding elements."
200
+ ),
201
+ ERR_MIXED_POSITIONAL_AND_NAMED_BINDS: (
202
+ "Positional and named bindings are not allowed to be used together"
203
+ ),
204
+ ERR_NAMED_TIMEZONE_NOT_SUPPORTED: (
205
+ "Other modes are incompatible with the use of named time zones"
206
+ ),
207
+ ERR_NO_STATEMENT: (
208
+ "Neither a statement is specified nor a prior one prepared"
209
+ ),
210
+ ERR_NO_STATEMENT_PREPARED: (
211
+ "statement should be prepared in advance"
212
+ ),
213
+ ERR_NOT_A_QUERY: (
214
+ "No rows are returned by the executed statement"
215
+ ),
216
+ ERR_NOT_CONNECTED: (
217
+ "The database connection is not established"
218
+ ),
219
+ ERR_NUMBER_STRING_OF_ZERO_LENGTH: "invalid number: zero length string",
220
+ ERR_NUMBER_STRING_TOO_LONG: "invalid number: string too long",
221
+ ERR_NUMBER_WITH_EMPTY_EXPONENT: "invalid number: empty exponent",
222
+ ERR_NUMBER_WITH_INVALID_EXPONENT: "invalid number: invalid exponent",
223
+ ERR_GBASE8S_NUMBER_NO_REPR: (
224
+ "The value is incapable of being expressed as a Gbase8s number"
225
+ ),
226
+ ERR_GBASE8S_TYPE_NAME_NOT_SUPPORTED: 'not support Gbase8s data type name "{name}"',
227
+ ERR_GBASE8S_TYPE_NOT_SUPPORTED: "not support Gbase8s data type {num}",
228
+ ERR_PYTHON_TYPE_NOT_SUPPORTED: "not support Python type {typ}",
229
+ ERR_PYTHON_VALUE_NOT_SUPPORTED: 'not support Python value of type "{type_name}"',
230
+ ERR_SELF_BIND_NOT_SUPPORTED: "binding to self is not supported",
231
+ ERR_TIME_NOT_SUPPORTED: (
232
+ "Gbase8s Database does not support time only variables"
233
+ ),
234
+ ERR_UNEXPECTED_END_OF_DATA: (
235
+ "unexpected end of data: want {num_bytes_wanted} bytes but "
236
+ "only {num_bytes_available} bytes are available"
237
+ ),
238
+ ERR_UNEXPECTED_NEGATIVE_INTEGER: (
239
+ "Internal error: a negative integer was read, "
240
+ "but a positive integer was anticipated"
241
+ ),
242
+ ERR_UNSUPPORTED_PYTHON_TYPE_FOR_DB_TYPE: (
243
+ "unsupported Python type {py_type_name} for database type "
244
+ "{db_type_name}"
245
+ ),
246
+ ERR_UNSUPPORTED_TYPE_SET: "type {db_type_name} does not support being set",
247
+ ERR_WRONG_ARRAY_DEFINITION: (
248
+ "expecting a list of two elements [type, numelems]"
249
+ ),
250
+ ERR_WRONG_EXECUTE_PARAMETERS_TYPE: (
251
+ "expecting a dictionary, list or tuple, or keyword args"
252
+ ),
253
+ ERR_WRONG_EXECUTEMANY_PARAMETERS_TYPE: (
254
+ 'For the "parameters" argument, a list of sequences '
255
+ 'or dictionaries is expected, '
256
+ "or alternatively, an integer to denote the execution count of the statement"
257
+ ),
258
+ ERR_INVALID_GCI_ATTR_TYPE: "invalid GCI attribute type {attr_type}",
259
+ ERR_INVALID_NUMBER: "invalid number",
260
+ ERR_INVALID_MAKEDSN_ARG: '"{name}" argument contains invalid values',
261
+ ERR_INVALID_LOB_OFFSET: "LOB offset must be greater than zero",
262
+ ERR_INVALID_LOB_AMOUNT: "LOB amount must be greater than zero",
263
+ ERR_INVALID_CONNECT_PARAMS: "invalid connection params",
264
+ ERR_INVALID_ARRAYSIZE: "arraysize must be an integer greater than zero",
265
+ ERR_INTEGER_TOO_LARGE: (
266
+ "internal error: read integer of length {length} when expecting "
267
+ "integer of no more than length {max_length}"
268
+ ),
269
+ ERR_INIT_GBASE8S_CLIENT_NOT_CALLED: (
270
+ "init_gbase8s_client() must be called first"
271
+ ),
272
+ ERR_INCORRECT_VAR_ARRAYSIZE: (
273
+ "variable array size of {var_arraysize} is "
274
+ "too small (should be at least {required_arraysize})"
275
+ ),
276
+ ERR_EXPECTING_VAR: (
277
+ "type handler should return None or the value returned by a call "
278
+ "to cursor.var()"
279
+ ),
280
+ ERR_EXPECTING_TYPE: "expected a type",
281
+ ERR_EXPECTING_LIST_FOR_ARRAY_VAR: (
282
+ "expecting list when setting array variables"
283
+ ),
284
+ ERR_DUPLICATED_PARAMETER: (
285
+ '"{deprecated_name}" and "{new_name}" cannot be specified together'
286
+ ),
287
+ ERR_DB_TYPE_NOT_SUPPORTED: 'database type "{name}" is not supported',
288
+ ERR_CURSOR_NOT_OPEN: "cursor is not open",
289
+ ERR_CURSOR_DIFF_CONNECTION: (
290
+ "It is not supported to bind a cursor from a different connection."
291
+ ),
292
+ ERR_CONTENT_INVALID_AFTER_NUMBER: "invalid number (content after number)",
293
+ ERR_BUFFER_LENGTH_INSUFFICIENT: (
294
+ "internal error: buffer of length {actual_buffer_len} "
295
+ "insufficient to hold {required_buffer_len} bytes"
296
+ ),
297
+ ERR_ARRAYS_OF_ARRAYS: "arrays of arrays are not supported",
298
+ ERR_ARGS_AND_KEYWORD_ARGS: (
299
+ "expecting positional arguments or keyword arguments, not both"
300
+ ),
301
+ ERR_ARGS_MUST_BE_LIST_OR_TUPLE: "arguments must be a list or tuple",
302
+ ERR_INVALID_ARGS: "Invalid arguments",
303
+ }
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+
3
+
4
+ class Warning(Exception):
5
+ pass
6
+
7
+
8
+ class Error(Exception):
9
+ pass
10
+
11
+
12
+ class DatabaseError(Error):
13
+ pass
14
+
15
+
16
+ class DataError(DatabaseError):
17
+ pass
18
+
19
+
20
+ class IntegrityError(DatabaseError):
21
+ pass
22
+
23
+
24
+ class InterfaceError(Error):
25
+ pass
26
+
27
+
28
+ class InternalError(DatabaseError):
29
+ pass
30
+
31
+
32
+ class NotSupportedError(DatabaseError):
33
+ pass
34
+
35
+
36
+ class OperationalError(DatabaseError):
37
+ pass
38
+
39
+
40
+ class ProgrammingError(DatabaseError):
41
+ pass
gbase8sdb/lob.py ADDED
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+
3
+ from typing import Any, Union
4
+
5
+
6
+ from . import __name__ as MODULE_NAME
7
+ from . import errors
8
+ from .driver import DB_TYPE_BLOB
9
+
10
+
11
+
12
+ class LOB:
13
+ __module__ = MODULE_NAME
14
+
15
+ def __str__(self):
16
+ return str(self.read())
17
+
18
+ def __del__(self):
19
+ self._cyobj.free_lob()
20
+
21
+ def __reduce__(self):
22
+ value = self.read()
23
+ return (type(value), (value,))
24
+
25
+
26
+ @classmethod
27
+ def _create_with_cyobj(cls, cyobj):
28
+ lob = cls.__new__(cls)
29
+ lob._cyobj = cyobj
30
+ return lob
31
+
32
+ def _check_value_to_write(self, value):
33
+ if isinstance(value, bytes):
34
+ if self.type is DB_TYPE_BLOB:
35
+ return value
36
+ else:
37
+ return value.decode('utf-8')
38
+ elif isinstance(value, str):
39
+ if self.type is DB_TYPE_BLOB:
40
+ return value.encode('utf-8')
41
+ else:
42
+ return value
43
+ else:
44
+ raise TypeError("expecting string or bytes")
45
+
46
+ def close(self):
47
+ self._cyobj.close()
48
+
49
+ def getchunksize(self):
50
+ return self._cyobj.get_chunk_size()
51
+
52
+ def isopen(self):
53
+ return self._cyobj.get_is_open()
54
+
55
+ def open(self):
56
+ self._cyobj.open()
57
+
58
+ def read(self, offset: int = 1, amount: int = None):
59
+ if amount is None:
60
+ amount = self._cyobj.get_max_amount()
61
+ if amount >= offset:
62
+ amount = amount - offset + 1
63
+ else:
64
+ amount = 1
65
+ elif amount <= 0:
66
+ errors.raise_error(errors.ERR_INVALID_LOB_AMOUNT)
67
+ if offset <= 0:
68
+ errors.raise_error(errors.ERR_INVALID_LOB_OFFSET)
69
+ return self._cyobj.read(offset, amount)
70
+
71
+ def size(self):
72
+ return self._cyobj.get_size()
73
+
74
+ def trim(self, new_size: int = 0, *, newSize: int = None):
75
+ if newSize is not None:
76
+ if new_size != 0:
77
+ errors.raise_error(
78
+ errors.ERR_DUPLICATED_PARAMETER,
79
+ deprecated_name="newSize",
80
+ new_name="new_size",
81
+ )
82
+ new_size = newSize
83
+ self._cyobj.trim(new_size)
84
+
85
+ def write(self, data: Union[str, bytes], offset: int = 1):
86
+ self._cyobj.write(self._check_value_to_write(data), offset)
87
+
88
+ @property
89
+ def type(self):
90
+ return self._cyobj.dbtype
gbase8sdb/var.py ADDED
@@ -0,0 +1,79 @@
1
+ # coding: utf-8
2
+
3
+ from typing import Any, Callable
4
+ from .driver import DbType
5
+
6
+
7
+ class Var:
8
+ def __repr__(self):
9
+ value = self._cyobj.get_all_values()
10
+ if not self._cyobj.is_array and len(value) == 1:
11
+ value = value[0]
12
+ typ = self._type
13
+ return f"<gbase8sdb.Var of type {typ.name} with value {repr(value)}>"
14
+
15
+ @classmethod
16
+ def _create_with_cyobj(cls, impl, typ=None):
17
+ var = cls.__new__(cls)
18
+ var._cyobj = impl
19
+ if typ is not None:
20
+ var._type = typ
21
+ else:
22
+ var._type = impl.dbtype
23
+ return var
24
+
25
+ @property
26
+ def actual_elements(self) -> int:
27
+ if self._cyobj.is_array:
28
+ return self._cyobj.num_elements_in_array
29
+ return self._cyobj.num_elements
30
+
31
+ @property
32
+ def actualElements(self) -> int:
33
+ return self.actual_elements
34
+
35
+ @property
36
+ def buffer_size(self) -> int:
37
+ return self._cyobj.buffer_size
38
+
39
+ @property
40
+ def bufferSize(self) -> int:
41
+ return self.buffer_size
42
+
43
+ @property
44
+ def convert_nulls(self) -> bool:
45
+ return self._cyobj.convert_nulls
46
+
47
+ def getvalue(self, pos: int = 0) -> Any:
48
+ return self._cyobj.get_value(pos)
49
+
50
+ @property
51
+ def inconverter(self) -> Callable:
52
+ return self._cyobj.inconverter
53
+
54
+ @property
55
+ def num_elements(self) -> int:
56
+ return self._cyobj.num_elements
57
+
58
+ @property
59
+ def numElements(self) -> int:
60
+ return self.num_elements
61
+
62
+ @property
63
+ def outconverter(self) -> Callable:
64
+ return self._cyobj.outconverter
65
+
66
+ def setvalue(self, pos: int, value: Any) -> None:
67
+ self._cyobj.set_value(pos, value)
68
+
69
+ @property
70
+ def size(self) -> int:
71
+ return self._cyobj.size
72
+
73
+ @property
74
+ def type(self) -> DbType:
75
+ return self._type
76
+
77
+ @property
78
+ def values(self) -> list:
79
+ return self._cyobj.get_all_values()
gbase8sdb/version.py ADDED
@@ -0,0 +1,7 @@
1
+ # coding: utf8
2
+ """
3
+ The version of the driver.
4
+ """
5
+
6
+ __version__ = ".".join(map(str, (0, 2, 1)))
7
+
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: gbase8sdb
3
+ Version: 0.2.1
4
+ Summary: Python interface to GBase 8s Database
5
+ License: MIT
6
+ Keywords: GBase 8s,database
7
+ Classifier: Development Status :: 5 - Production/Stable
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Natural Language :: English
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: Implementation :: CPython
14
+ Classifier: Programming Language :: Cython
15
+ Classifier: Topic :: Database
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE.txt
19
+ License-File: THIRD_PARTY_LICENSES.txt
20
+ Dynamic: license-file
21
+
22
+ # python-gbase8sdb
23
+
24
+ python-gbase8sdb 是一个 [Python 编程语言][python] 扩展模块,允许 Python 程序连接到 GBase 8s 数据库。
25
+
26
+ 该模块符合 [Python 数据库 API 2.0 规范][pep249],并且包含大量扩展和少数排除项。
27
+
28
+
29
+ ## 安装
30
+
31
+ 运行 `python -m pip install gbase8sdb` 安装。
32
+
33
+
34
+ ## 依赖和互操作性
35
+
36
+ - 支持的 Python 版本:3.8 至 3.13 。
37
+
38
+ - 支持的 GBase 8s 数据库版本:GBase 8s V8.8_3.6.2版本及以上。
39
+
40
+ - 支持的操作系统:Linux x86_64、 Windows 64位操作系统 。
41
+
42
+ - 依赖 GSDK 1.1 版本。
43
+
44
+
45
+ #### 使用说明
46
+
47
+ 1. gbase8sdb驱动连接数据库依赖GSDK,所以您需要联系GBase 8s技术支持或通过官方渠道获取相应版本的GSDK,并安装到您的机器上, 并设置如下环境变量:
48
+
49
+ - Linux系统:
50
+ ```bash
51
+ GSDK_PATH=/path/to/gsdk
52
+ export LD_LIBRARY_PATH=${GSDK_PATH}/lib:$LD_LIBRARY_PATH
53
+ export GBASEDBTDIR=${GSDK_PATH}/lib
54
+ ```
55
+
56
+ - Windows系统:
57
+
58
+ ```cmd
59
+ GSDK_PATH=\path\to\gsdk
60
+ set PATH=%GSDK_PATH%\lib;%PATH%
61
+ set GBASEDBTDIR=%GSDK_PATH%\lib
62
+ ```
63
+
64
+ #### 入门
65
+ 在您的Python应用程序中,可以通过以下方式连接到数据库:
66
+ ```python
67
+ import gbase8sdb
68
+
69
+ # 生成dsn
70
+ dsn = gbase8sdb.makedsn(
71
+ server_name="ol_gbasedbt1210_2", # 数据库实例名称
72
+ db_name="testdbutf8", # 数据库名称
73
+ host="192.168.xxx.xxx", # 数据库实例所在服务器的IP地址或域名
74
+ port=9088, # 数据库实例的端口号
75
+ db_locale='zh_CN.utf8' # 数据库字符集
76
+ )
77
+ user = "gbasedbt" # 数据库用户名
78
+ password = "xxxxxx" # 数据库用户密码
79
+
80
+ # 连接数据库
81
+ conn = gbase8sdb.connect(dsn, user, password)
82
+ # 创建游标
83
+ cursor = conn.cursor()
84
+ # 执行SQL语句
85
+ cursor.execute("drop table if exists t")
86
+ cursor.execute("create table t (id int, name varchar(20))")
87
+ cursor.execute("insert into t values (?, ?)", (1, "zhangsan"))
88
+ cursor.execute("select * from t")
89
+ # 获取查询结果
90
+ print(cursor.fetchall())
91
+ # 关闭游标和连接
92
+ cursor.close()
93
+ conn.close()
94
+ ```
95
+
@@ -0,0 +1,19 @@
1
+ gbase8sdb/__init__.py,sha256=1ajotGGMb-joNKKi7nUKn5gTy48qBQAuze4EecMIF3o,2946
2
+ gbase8sdb/column_metadata.py,sha256=OjCsICwH1D8XIs5uM4FfBrKese2U7Bc-WYWC9JPEeTA,2793
3
+ gbase8sdb/connection.py,sha256=611ZmiNWf3TYNt55btwzvbqeN8A201XyPk2vZF0zvNU,4410
4
+ gbase8sdb/constructors.py,sha256=qXtsZ8Nyiq5wrlaSrN3lR7JYwUw7NcqIB9dsmgqoaNU,900
5
+ gbase8sdb/cursor.py,sha256=pgACZ11dAeOcooOoi2ArtkNWGA5oTPkDDQ4M7bafEhg,12350
6
+ gbase8sdb/defaults.py,sha256=KnjFBKnK4vnIjAN128spKEI7PB3DHypzNMTkwcUcyIw,993
7
+ gbase8sdb/driver.cpython-310-aarch64-linux-gnu.so,sha256=Nr88ZXrppFPe3uxYWeYU_YmfHTAWCgEucfclXQjRMqs,5981200
8
+ gbase8sdb/dsn.py,sha256=LkQmQWebvUsPWcIxMLHj1yh6NxDgwx4hQcPZHNijEas,1552
9
+ gbase8sdb/errors.py,sha256=_BK0qTTnukbJ3N6JEyxSMRnYZ3OQgwZPyUks0iI4ULY,11027
10
+ gbase8sdb/exceptions.py,sha256=SjWBklHYQDIcQ1asBU2FDbvx94x_O89P6rC-7gDfpPA,456
11
+ gbase8sdb/lob.py,sha256=hJnTzKfzhVJo4Cgknpyxhmcm0ZN-cy8Qvtt1hHIvIUg,2368
12
+ gbase8sdb/var.py,sha256=zDEjUiijrpFeEUFeepFobT1GyazTEaUqi4MrqnxC2PY,1904
13
+ gbase8sdb/version.py,sha256=KmUSBsPG3q90ARyQ63M792UgARfKGObOY74G8H11XIk,96
14
+ gbase8sdb-0.2.1.dist-info/METADATA,sha256=nINMOROcwpufQuDOJpg_sNx9OMidW9Gmw41CP7psRUQ,2870
15
+ gbase8sdb-0.2.1.dist-info/WHEEL,sha256=4cXYjjYwj_5xiOKzOrsPqM6JPninWecARCUwbOLhJXk,153
16
+ gbase8sdb-0.2.1.dist-info/top_level.txt,sha256=5M_P75jEB53qPfRObJmPBMDvuPGpZil5omAJAMlaqlI,10
17
+ gbase8sdb-0.2.1.dist-info/RECORD,,
18
+ gbase8sdb-0.2.1.dist-info/licenses/LICENSE.txt,sha256=kDUGdWcTVtXFktGLHB-glp1LI92-VW5ipQlAVR4WKP4,1083
19
+ gbase8sdb-0.2.1.dist-info/licenses/THIRD_PARTY_LICENSES.txt,sha256=88_Bn1SLiGFNZq9HNBedps7zemgR50FRat29TWtFkj4,28103
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.3.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-manylinux_2_17_aarch64
5
+ Tag: cp310-cp310-manylinux2014_aarch64
6
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2025 GBASE Technologies Co.,Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.