BCBvcl4pyAPI 0.1.3__tar.gz → 0.1.6__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.
- bcbvcl4pyapi-0.1.6/LICENSE +20 -0
- bcbvcl4pyapi-0.1.6/PKG-INFO +43 -0
- bcbvcl4pyapi-0.1.6/README.md +11 -0
- {bcbvcl4pyapi-0.1.3 → bcbvcl4pyapi-0.1.6}/pyproject.toml +7 -1
- bcbvcl4pyapi-0.1.6/src/BCBvcl4pyAPI/AnsiStringAPI.py +174 -0
- bcbvcl4pyapi-0.1.6/src/BCBvcl4pyAPI/HyperDynamicArrayAPI.py +137 -0
- bcbvcl4pyapi-0.1.6/src/BCBvcl4pyAPI/__init__.py +5 -0
- bcbvcl4pyapi-0.1.6/src/BCBvcl4pyAPI.egg-info/PKG-INFO +43 -0
- bcbvcl4pyapi-0.1.6/src/BCBvcl4pyAPI.egg-info/SOURCES.txt +16 -0
- bcbvcl4pyapi-0.1.6/src/BCBvcl4pyAPI.egg-info/requires.txt +1 -0
- {bcbvcl4pyapi-0.1.3 → bcbvcl4pyapi-0.1.6/src}/BCBvcl4pyAPI.egg-info/top_level.txt +1 -0
- bcbvcl4pyapi-0.1.6/src/Example/PyListTest.py +25 -0
- bcbvcl4pyapi-0.1.6/src/Example/PyListTest2.py +19 -0
- bcbvcl4pyapi-0.1.6/src/Example/TestHyperList.py +38 -0
- bcbvcl4pyapi-0.1.3/BCBvcl4pyAPI/__init__.py +0 -3
- bcbvcl4pyapi-0.1.3/BCBvcl4pyAPI.egg-info/PKG-INFO +0 -11
- bcbvcl4pyapi-0.1.3/BCBvcl4pyAPI.egg-info/SOURCES.txt +0 -9
- bcbvcl4pyapi-0.1.3/PKG-INFO +0 -11
- bcbvcl4pyapi-0.1.3/README.md +0 -3
- {bcbvcl4pyapi-0.1.3 → bcbvcl4pyapi-0.1.6}/setup.cfg +0 -0
- {bcbvcl4pyapi-0.1.3 → bcbvcl4pyapi-0.1.6/src}/BCBvcl4pyAPI/BCBvcl4pyAPI.py +0 -0
- {bcbvcl4pyapi-0.1.3 → bcbvcl4pyapi-0.1.6/src}/BCBvcl4pyAPI.egg-info/dependency_links.txt +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2025 James Lin
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is granted for **personal, educational, or non-commercial use only**.
|
|
6
|
+
You **may NOT**:
|
|
7
|
+
|
|
8
|
+
1. Sell or otherwise commercially exploit this software or any part of it.
|
|
9
|
+
2. Reproduce, distribute, or sublicense this software for commercial purposes.
|
|
10
|
+
3. Modify or create derivative works for commercial purposes without explicit written permission from the copyright holder.
|
|
11
|
+
|
|
12
|
+
You **may**:
|
|
13
|
+
|
|
14
|
+
- Use the software for personal learning, research, or internal company evaluation (non-commercial).
|
|
15
|
+
- Share the software with attribution to the original author, as long as it is not for commercial gain.
|
|
16
|
+
|
|
17
|
+
**Disclaimer:**
|
|
18
|
+
This software is provided "AS IS", without any warranty of any kind, either expressed or implied,
|
|
19
|
+
including but not limited to the warranties of merchantability, fitness for a particular purpose, or non-infringement.
|
|
20
|
+
In no event shall the author be liable for any claim, damages, or other liability arising from, out of, or in connection with the software or its use.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: BCBvcl4pyAPI
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: BCBvcl4pyAPI Python package
|
|
5
|
+
Author-email: James Lin <tylin123@ms27.hinet.net>
|
|
6
|
+
License: Copyright (c) 2025 James Lin
|
|
7
|
+
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Permission is granted for **personal, educational, or non-commercial use only**.
|
|
11
|
+
You **may NOT**:
|
|
12
|
+
|
|
13
|
+
1. Sell or otherwise commercially exploit this software or any part of it.
|
|
14
|
+
2. Reproduce, distribute, or sublicense this software for commercial purposes.
|
|
15
|
+
3. Modify or create derivative works for commercial purposes without explicit written permission from the copyright holder.
|
|
16
|
+
|
|
17
|
+
You **may**:
|
|
18
|
+
|
|
19
|
+
- Use the software for personal learning, research, or internal company evaluation (non-commercial).
|
|
20
|
+
- Share the software with attribution to the original author, as long as it is not for commercial gain.
|
|
21
|
+
|
|
22
|
+
**Disclaimer:**
|
|
23
|
+
This software is provided "AS IS", without any warranty of any kind, either expressed or implied,
|
|
24
|
+
including but not limited to the warranties of merchantability, fitness for a particular purpose, or non-infringement.
|
|
25
|
+
In no event shall the author be liable for any claim, damages, or other liability arising from, out of, or in connection with the software or its use.
|
|
26
|
+
|
|
27
|
+
Project-URL: Homepage, https://mis.gotech.biz
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: pymysql
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
#BCBvcl4pyAPI
|
|
34
|
+
|
|
35
|
+
## History of version
|
|
36
|
+
Version 0.1.3: 2025/09/19<BR>
|
|
37
|
+
Mainly fixed the issue where Packages could not be found after an update.<BR>
|
|
38
|
+
|
|
39
|
+
Version 0.1.5: 2025/09/20<BR>
|
|
40
|
+
Add the HyperDynamicArray class to provide large memory access functionality.<BR>
|
|
41
|
+
|
|
42
|
+
Version 0.1.6: 2025/10/08<BR>
|
|
43
|
+
Add the AnsiString class
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#BCBvcl4pyAPI
|
|
2
|
+
|
|
3
|
+
## History of version
|
|
4
|
+
Version 0.1.3: 2025/09/19<BR>
|
|
5
|
+
Mainly fixed the issue where Packages could not be found after an update.<BR>
|
|
6
|
+
|
|
7
|
+
Version 0.1.5: 2025/09/20<BR>
|
|
8
|
+
Add the HyperDynamicArray class to provide large memory access functionality.<BR>
|
|
9
|
+
|
|
10
|
+
Version 0.1.6: 2025/10/08<BR>
|
|
11
|
+
Add the AnsiString class
|
|
@@ -4,13 +4,19 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "BCBvcl4pyAPI"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.6"
|
|
8
8
|
description = "BCBvcl4pyAPI Python package"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name="James Lin", email="tylin123@ms27.hinet.net" }
|
|
11
11
|
]
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
license = { file = "LICENSE" }
|
|
14
|
+
dependencies = [
|
|
15
|
+
"pymysql",
|
|
16
|
+
]
|
|
14
17
|
|
|
15
18
|
[project.urls]
|
|
16
19
|
Homepage = "https://mis.gotech.biz"
|
|
20
|
+
|
|
21
|
+
[tools.setuptools.packages.find]
|
|
22
|
+
where = ["src"]
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
class AnsiString:
|
|
2
|
+
def __init__(self, Pms_str: str = '', encoding: str = 'byte'):
|
|
3
|
+
"""
|
|
4
|
+
encoding:
|
|
5
|
+
'byte' -> BCB5 byte模式(中文佔兩個byte)
|
|
6
|
+
'unicode' -> Unicode 字元模式
|
|
7
|
+
"""
|
|
8
|
+
self.encoding = encoding
|
|
9
|
+
self.set(Pms_str)
|
|
10
|
+
|
|
11
|
+
# ---------------------------------------------
|
|
12
|
+
# 改變內容
|
|
13
|
+
# ---------------------------------------------
|
|
14
|
+
def set(self, Pms_str: str):
|
|
15
|
+
if self.encoding == 'byte':
|
|
16
|
+
self._data = Pms_str.encode('big5', errors='replace')
|
|
17
|
+
else:
|
|
18
|
+
self._data = Pms_str.encode('utf-8')
|
|
19
|
+
return self # 支援連鎖呼叫
|
|
20
|
+
|
|
21
|
+
# ---------------------------------------------
|
|
22
|
+
# 轉成 Python str
|
|
23
|
+
# ---------------------------------------------
|
|
24
|
+
def str(self):
|
|
25
|
+
if self.encoding == 'byte':
|
|
26
|
+
return self._data.decode('big5', errors='replace')
|
|
27
|
+
else:
|
|
28
|
+
return self._data.decode('utf-8')
|
|
29
|
+
|
|
30
|
+
def __str__(self):
|
|
31
|
+
return self.str()
|
|
32
|
+
|
|
33
|
+
# ---------------------------------------------
|
|
34
|
+
# 取 C 字串 bytes
|
|
35
|
+
# ---------------------------------------------
|
|
36
|
+
def c_str(self):
|
|
37
|
+
return self._data
|
|
38
|
+
|
|
39
|
+
# ---------------------------------------------
|
|
40
|
+
# 支援索引取單 byte
|
|
41
|
+
# ---------------------------------------------
|
|
42
|
+
def __getitem__(self, index):
|
|
43
|
+
return self._data[index]
|
|
44
|
+
|
|
45
|
+
# ---------------------------------------------
|
|
46
|
+
# SubString
|
|
47
|
+
# mode='byte' / 'unicode'
|
|
48
|
+
# ---------------------------------------------
|
|
49
|
+
def SubString(self, start: int, length: int = None, mode: str = None):
|
|
50
|
+
mode = mode or self.encoding
|
|
51
|
+
if mode == 'unicode':
|
|
52
|
+
s = self.str()
|
|
53
|
+
start -= 1
|
|
54
|
+
if length is None:
|
|
55
|
+
return AnsiString(s[start:], encoding=self.encoding)
|
|
56
|
+
else:
|
|
57
|
+
return AnsiString(s[start:start+length], encoding=self.encoding)
|
|
58
|
+
elif mode == 'byte':
|
|
59
|
+
start -= 1
|
|
60
|
+
if length is None:
|
|
61
|
+
return AnsiString(self._data[start:].decode('big5', errors='replace'), encoding=self.encoding)
|
|
62
|
+
else:
|
|
63
|
+
return AnsiString(self._data[start:start+length].decode('big5', errors='replace'), encoding=self.encoding)
|
|
64
|
+
else:
|
|
65
|
+
raise ValueError("mode must be 'byte' or 'unicode'")
|
|
66
|
+
|
|
67
|
+
# ---------------------------------------------
|
|
68
|
+
# 長度
|
|
69
|
+
# ---------------------------------------------
|
|
70
|
+
def Length(self, mode: str = None):
|
|
71
|
+
mode = mode or self.encoding
|
|
72
|
+
if mode == 'unicode':
|
|
73
|
+
return len(self.str())
|
|
74
|
+
elif mode == 'byte':
|
|
75
|
+
return len(self._data)
|
|
76
|
+
else:
|
|
77
|
+
raise ValueError("mode must be 'byte' or 'unicode'")
|
|
78
|
+
|
|
79
|
+
@staticmethod
|
|
80
|
+
def strlen(Pms_str: str, encoding: str = 'byte'):
|
|
81
|
+
if encoding == 'unicode':
|
|
82
|
+
return len(Pms_str)
|
|
83
|
+
elif encoding == 'byte':
|
|
84
|
+
return len(Pms_str.encode('big5', errors='replace'))
|
|
85
|
+
else:
|
|
86
|
+
raise ValueError("encoding must be 'byte' or 'unicode'")
|
|
87
|
+
|
|
88
|
+
# ---------------------------------------------
|
|
89
|
+
# 常用方法
|
|
90
|
+
# ---------------------------------------------
|
|
91
|
+
def Trim(self):
|
|
92
|
+
return AnsiString(self.str().strip(), encoding=self.encoding)
|
|
93
|
+
|
|
94
|
+
def UpperCase(self):
|
|
95
|
+
return AnsiString(self.str().upper(), encoding=self.encoding)
|
|
96
|
+
|
|
97
|
+
def LowerCase(self):
|
|
98
|
+
return AnsiString(self.str().lower(), encoding=self.encoding)
|
|
99
|
+
|
|
100
|
+
def Pos(self, sub: str):
|
|
101
|
+
idx = self.str().find(sub)
|
|
102
|
+
return idx + 1 if idx >= 0 else 0
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def StringOfChar(char: str, count: int, encoding='byte'):
|
|
106
|
+
return AnsiString(char * count, encoding=encoding)
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def sprintf(fmt: str, *args, encoding='byte'):
|
|
110
|
+
return AnsiString(fmt % args, encoding=encoding)
|
|
111
|
+
|
|
112
|
+
# ---------------------------------------------
|
|
113
|
+
# + 運算子
|
|
114
|
+
# ---------------------------------------------
|
|
115
|
+
def __add__(self, other):
|
|
116
|
+
if isinstance(other, AnsiString):
|
|
117
|
+
combined_str = self.str() + other.str()
|
|
118
|
+
elif isinstance(other, str):
|
|
119
|
+
combined_str = self.str() + other
|
|
120
|
+
else:
|
|
121
|
+
raise TypeError("Can only add AnsiString or str")
|
|
122
|
+
return AnsiString(combined_str, encoding=self.encoding)
|
|
123
|
+
|
|
124
|
+
# ---------------------------------------------
|
|
125
|
+
# += 原地累加
|
|
126
|
+
# ---------------------------------------------
|
|
127
|
+
def __iadd__(self, other):
|
|
128
|
+
if isinstance(other, AnsiString):
|
|
129
|
+
new_str = self.str() + other.str()
|
|
130
|
+
elif isinstance(other, str):
|
|
131
|
+
new_str = self.str() + other
|
|
132
|
+
else:
|
|
133
|
+
raise TypeError("Can only add AnsiString or str")
|
|
134
|
+
if self.encoding == 'byte':
|
|
135
|
+
self._data = new_str.encode('big5', errors='replace')
|
|
136
|
+
else:
|
|
137
|
+
self._data = new_str.encode('utf-8')
|
|
138
|
+
return self
|
|
139
|
+
|
|
140
|
+
# ================================================================================
|
|
141
|
+
if(__name__=="__main__"):
|
|
142
|
+
s = AnsiString(" test--測試1234 ")
|
|
143
|
+
|
|
144
|
+
# 連鎖呼叫
|
|
145
|
+
result = s.Trim().UpperCase().SubString(3,5)
|
|
146
|
+
print(str(result)) # 結果: "ST--測試1"
|
|
147
|
+
|
|
148
|
+
# 改變內容也可以連鎖
|
|
149
|
+
s.set("abc 中文").UpperCase().Trim()
|
|
150
|
+
print(str(s)) # "ABC 中文"
|
|
151
|
+
|
|
152
|
+
# 取長度
|
|
153
|
+
print(s.Length()) # byte 長度
|
|
154
|
+
print(s.Length(mode='unicode')) # 字元長度
|
|
155
|
+
|
|
156
|
+
# 靜態 strlen
|
|
157
|
+
ms_MyStr = "test--測試1234"
|
|
158
|
+
mi_Len = AnsiString.strlen(ms_MyStr, encoding="unicode")
|
|
159
|
+
print("mi_Len unicode:", mi_Len)
|
|
160
|
+
mi_Len_byte = AnsiString.strlen(ms_MyStr, encoding="byte")
|
|
161
|
+
print("mi_Len byte:", mi_Len_byte)
|
|
162
|
+
|
|
163
|
+
# SubString byte/unicode
|
|
164
|
+
print(str(s.SubString(2,3))) # byte模式
|
|
165
|
+
print(str(s.SubString(2,3, mode='unicode'))) # unicode模式
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
s.set(str(ms_MyStr))
|
|
169
|
+
print(s.str()) # "新的字串" -> 大寫 "新的字串"
|
|
170
|
+
print(s.Pos("測"))
|
|
171
|
+
|
|
172
|
+
print(f"[{s}] ----> len1={s.Length()}");
|
|
173
|
+
s+="-->增加字";
|
|
174
|
+
print(f"[{s}] ----> len2={s.Length()}");
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pickle
|
|
3
|
+
from typing import Generic, TypeVar, Optional
|
|
4
|
+
import pymysql
|
|
5
|
+
from dataclasses import is_dataclass
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T")
|
|
8
|
+
|
|
9
|
+
class HyperDynamicArray(Generic[T]):
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
mysql_host: str,
|
|
13
|
+
mysql_port: int,
|
|
14
|
+
mysql_user: str,
|
|
15
|
+
mysql_password: str,
|
|
16
|
+
mysql_db: str,
|
|
17
|
+
table_name: str = "dynamic_array_table",
|
|
18
|
+
pickle_file: Optional[str] = None,
|
|
19
|
+
table_type: str = "standard", # "standard" = InnoDB, "memory" = MEMORY
|
|
20
|
+
sample_element: Optional[T] = None # 用來檢測元素型別
|
|
21
|
+
):
|
|
22
|
+
self.mysql_host = mysql_host
|
|
23
|
+
self.mysql_port = mysql_port
|
|
24
|
+
self.mysql_user = mysql_user
|
|
25
|
+
self.mysql_password = mysql_password
|
|
26
|
+
self.mysql_db = mysql_db
|
|
27
|
+
self.table_name = table_name
|
|
28
|
+
self._count = 0
|
|
29
|
+
|
|
30
|
+
# 初始化 table_type
|
|
31
|
+
self.table_type = table_type.lower()
|
|
32
|
+
if self.table_type not in ("standard", "memory"):
|
|
33
|
+
raise ValueError("table_type must be 'standard' or 'memory'")
|
|
34
|
+
|
|
35
|
+
# 自動切換 MEMORY / InnoDB
|
|
36
|
+
if self.table_type == "memory":
|
|
37
|
+
if sample_element is None:
|
|
38
|
+
# 無法判斷元素型別,安全起見改標準 table
|
|
39
|
+
print("⚠ Cannot determine element type, using standard table (InnoDB)")
|
|
40
|
+
self.table_type = "standard"
|
|
41
|
+
else:
|
|
42
|
+
if is_dataclass(sample_element) or not isinstance(sample_element, (int, float, str)):
|
|
43
|
+
# dataclass 或任意 Python 物件 → 改 InnoDB
|
|
44
|
+
print("⚠ Dataclass / Python object not supported in MEMORY Table, switching to standard table (InnoDB)")
|
|
45
|
+
self.table_type = "standard"
|
|
46
|
+
elif isinstance(sample_element, str):
|
|
47
|
+
# 字串超長也改 InnoDB
|
|
48
|
+
if len(sample_element.encode("utf-8")) > 65532:
|
|
49
|
+
print("⚠ String exceeds MEMORY Table maximum length, switching to standard table (InnoDB)")
|
|
50
|
+
self.table_type = "standard"
|
|
51
|
+
|
|
52
|
+
# 建立 pymysql 連線
|
|
53
|
+
self._conn = pymysql.connect(
|
|
54
|
+
host=mysql_host,
|
|
55
|
+
port=mysql_port,
|
|
56
|
+
user=mysql_user,
|
|
57
|
+
password=mysql_password,
|
|
58
|
+
database=mysql_db,
|
|
59
|
+
autocommit=True,
|
|
60
|
+
charset='utf8mb4',
|
|
61
|
+
cursorclass=pymysql.cursors.Cursor
|
|
62
|
+
)
|
|
63
|
+
self._cursor = self._conn.cursor()
|
|
64
|
+
|
|
65
|
+
# 建立 table
|
|
66
|
+
self._create_table()
|
|
67
|
+
|
|
68
|
+
# 如果有 pickle_file,轉入 MySQL
|
|
69
|
+
if pickle_file and os.path.exists(pickle_file):
|
|
70
|
+
self._load_pickle_to_mysql(pickle_file)
|
|
71
|
+
|
|
72
|
+
# 計算元素總數
|
|
73
|
+
self._cursor.execute(f"SELECT COUNT(*) FROM {self.table_name}")
|
|
74
|
+
self._count = self._cursor.fetchone()[0]
|
|
75
|
+
|
|
76
|
+
def _create_table(self):
|
|
77
|
+
engine = "InnoDB" if self.table_type == "standard" else "MEMORY"
|
|
78
|
+
# MEMORY Table 只能用 VARBINARY(65532)
|
|
79
|
+
column_def = "LONGBLOB" if engine == "InnoDB" else "VARBINARY(65532)"
|
|
80
|
+
create_sql = f"""
|
|
81
|
+
CREATE TABLE IF NOT EXISTS {self.table_name} (
|
|
82
|
+
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
|
83
|
+
data {column_def}
|
|
84
|
+
) ENGINE={engine};
|
|
85
|
+
"""
|
|
86
|
+
self._cursor.execute(create_sql)
|
|
87
|
+
|
|
88
|
+
def _load_pickle_to_mysql(self, pickle_file: str):
|
|
89
|
+
with open(pickle_file, "rb") as f:
|
|
90
|
+
try:
|
|
91
|
+
while True:
|
|
92
|
+
item = pickle.load(f)
|
|
93
|
+
self.Add(item)
|
|
94
|
+
except EOFError:
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
def Add(self, value: T) -> int:
|
|
98
|
+
data_blob = pickle.dumps(value)
|
|
99
|
+
sql = f"INSERT INTO {self.table_name} (data) VALUES (%s)"
|
|
100
|
+
self._cursor.execute(sql, (data_blob,))
|
|
101
|
+
self._count += 1
|
|
102
|
+
return self._count - 1
|
|
103
|
+
|
|
104
|
+
def Count(self) -> int:
|
|
105
|
+
return self._count
|
|
106
|
+
|
|
107
|
+
def __getitem__(self, index: int) -> T:
|
|
108
|
+
if index < 0 or index >= self._count:
|
|
109
|
+
raise IndexError("HyperDynamicArray index out of range")
|
|
110
|
+
sql = f"SELECT data FROM {self.table_name} WHERE id = %s"
|
|
111
|
+
self._cursor.execute(sql, (index + 1,))
|
|
112
|
+
row = self._cursor.fetchone()
|
|
113
|
+
if row:
|
|
114
|
+
return pickle.loads(row[0])
|
|
115
|
+
else:
|
|
116
|
+
raise IndexError("HyperDynamicArray index not found")
|
|
117
|
+
|
|
118
|
+
def __setitem__(self, index: int, value: T):
|
|
119
|
+
if index < 0 or index >= self._count:
|
|
120
|
+
raise IndexError("HyperDynamicArray index out of range")
|
|
121
|
+
data_blob = pickle.dumps(value)
|
|
122
|
+
sql = f"UPDATE {self.table_name} SET data = %s WHERE id = %s"
|
|
123
|
+
self._cursor.execute(sql, (data_blob, index + 1))
|
|
124
|
+
|
|
125
|
+
def __iter__(self):
|
|
126
|
+
for i in range(self._count):
|
|
127
|
+
yield self[i]
|
|
128
|
+
|
|
129
|
+
def Clear(self):
|
|
130
|
+
"""清空 table"""
|
|
131
|
+
sql = f"TRUNCATE TABLE {self.table_name}"
|
|
132
|
+
self._cursor.execute(sql)
|
|
133
|
+
self._count = 0
|
|
134
|
+
|
|
135
|
+
def Close(self):
|
|
136
|
+
self._cursor.close()
|
|
137
|
+
self._conn.close()
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: BCBvcl4pyAPI
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: BCBvcl4pyAPI Python package
|
|
5
|
+
Author-email: James Lin <tylin123@ms27.hinet.net>
|
|
6
|
+
License: Copyright (c) 2025 James Lin
|
|
7
|
+
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Permission is granted for **personal, educational, or non-commercial use only**.
|
|
11
|
+
You **may NOT**:
|
|
12
|
+
|
|
13
|
+
1. Sell or otherwise commercially exploit this software or any part of it.
|
|
14
|
+
2. Reproduce, distribute, or sublicense this software for commercial purposes.
|
|
15
|
+
3. Modify or create derivative works for commercial purposes without explicit written permission from the copyright holder.
|
|
16
|
+
|
|
17
|
+
You **may**:
|
|
18
|
+
|
|
19
|
+
- Use the software for personal learning, research, or internal company evaluation (non-commercial).
|
|
20
|
+
- Share the software with attribution to the original author, as long as it is not for commercial gain.
|
|
21
|
+
|
|
22
|
+
**Disclaimer:**
|
|
23
|
+
This software is provided "AS IS", without any warranty of any kind, either expressed or implied,
|
|
24
|
+
including but not limited to the warranties of merchantability, fitness for a particular purpose, or non-infringement.
|
|
25
|
+
In no event shall the author be liable for any claim, damages, or other liability arising from, out of, or in connection with the software or its use.
|
|
26
|
+
|
|
27
|
+
Project-URL: Homepage, https://mis.gotech.biz
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: pymysql
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
#BCBvcl4pyAPI
|
|
34
|
+
|
|
35
|
+
## History of version
|
|
36
|
+
Version 0.1.3: 2025/09/19<BR>
|
|
37
|
+
Mainly fixed the issue where Packages could not be found after an update.<BR>
|
|
38
|
+
|
|
39
|
+
Version 0.1.5: 2025/09/20<BR>
|
|
40
|
+
Add the HyperDynamicArray class to provide large memory access functionality.<BR>
|
|
41
|
+
|
|
42
|
+
Version 0.1.6: 2025/10/08<BR>
|
|
43
|
+
Add the AnsiString class
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
src/BCBvcl4pyAPI/AnsiStringAPI.py
|
|
6
|
+
src/BCBvcl4pyAPI/BCBvcl4pyAPI.py
|
|
7
|
+
src/BCBvcl4pyAPI/HyperDynamicArrayAPI.py
|
|
8
|
+
src/BCBvcl4pyAPI/__init__.py
|
|
9
|
+
src/BCBvcl4pyAPI.egg-info/PKG-INFO
|
|
10
|
+
src/BCBvcl4pyAPI.egg-info/SOURCES.txt
|
|
11
|
+
src/BCBvcl4pyAPI.egg-info/dependency_links.txt
|
|
12
|
+
src/BCBvcl4pyAPI.egg-info/requires.txt
|
|
13
|
+
src/BCBvcl4pyAPI.egg-info/top_level.txt
|
|
14
|
+
src/Example/PyListTest.py
|
|
15
|
+
src/Example/PyListTest2.py
|
|
16
|
+
src/Example/TestHyperList.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pymysql
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from BCBvcl4pyAPI import TStringList
|
|
2
|
+
from BCBvcl4pyAPI import DynamicArray
|
|
3
|
+
|
|
4
|
+
mi_c : int = 0;
|
|
5
|
+
|
|
6
|
+
obj_StrList = TStringList();
|
|
7
|
+
|
|
8
|
+
obj_StrList.Add("Str--1");
|
|
9
|
+
obj_StrList.Add("Str--2");
|
|
10
|
+
|
|
11
|
+
print();
|
|
12
|
+
for mi_c in range(0, obj_StrList.Count()):
|
|
13
|
+
print(f"data {mi_c}: {obj_StrList[mi_c]}");
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
mda_Values = DynamicArray[float]();
|
|
17
|
+
|
|
18
|
+
mda_Values.Add(1.2);
|
|
19
|
+
mda_Values.Add(2.2);
|
|
20
|
+
mda_Values.Add(3.2);
|
|
21
|
+
mda_Values.Add(4.2);
|
|
22
|
+
mda_Values.Add(5.2);
|
|
23
|
+
|
|
24
|
+
for mi_c in range(0, mda_Values.Length()):
|
|
25
|
+
print(f"data_float = {mda_Values[mi_c]}");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from BCBvcl4pyAPI import TStringList
|
|
2
|
+
from BCBvcl4pyAPI import DynamicArray
|
|
3
|
+
|
|
4
|
+
obj_MyList : TStringList;
|
|
5
|
+
mda_MyValues : DynamicArray;
|
|
6
|
+
mi_c : int = 0;
|
|
7
|
+
|
|
8
|
+
mda_MyValues = DynamicArray();
|
|
9
|
+
|
|
10
|
+
mda_MyValues.Add(0.319);
|
|
11
|
+
mda_MyValues.Add(4.123);
|
|
12
|
+
mda_MyValues.Add(3.621);
|
|
13
|
+
|
|
14
|
+
for mi_c in range(0, mda_MyValues.Length()):
|
|
15
|
+
print(mda_MyValues[mi_c]);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
obj_MyList = TStringList();
|
|
19
|
+
obj_MyList.Add("OKOK");
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from BCBvcl4pyAPI import HyperDynamicArray
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class TPerson:
|
|
6
|
+
name: str
|
|
7
|
+
age: int
|
|
8
|
+
|
|
9
|
+
# 建立記憶體 table 模式
|
|
10
|
+
arr = HyperDynamicArray[TPerson](
|
|
11
|
+
mysql_host="mis.gotech.biz",
|
|
12
|
+
mysql_port= 3300,
|
|
13
|
+
mysql_user="root",
|
|
14
|
+
mysql_password="gotechdf8000sys",
|
|
15
|
+
mysql_db="df8000",
|
|
16
|
+
table_name="_mem_dataset",
|
|
17
|
+
table_type="memory"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
arr.Clear();
|
|
21
|
+
|
|
22
|
+
# 加入元素
|
|
23
|
+
for i in range(500):
|
|
24
|
+
arr.Add(TPerson(f"Person{i}", 20+i))
|
|
25
|
+
|
|
26
|
+
print("元素總數:", arr.Count())
|
|
27
|
+
|
|
28
|
+
# 讀取
|
|
29
|
+
for i in range(arr.Count()):
|
|
30
|
+
print(arr[i])
|
|
31
|
+
|
|
32
|
+
print(arr[106].name);
|
|
33
|
+
|
|
34
|
+
# 清空 table
|
|
35
|
+
#arr.Clear()
|
|
36
|
+
#print("清空後元素總數:", arr.Count())
|
|
37
|
+
|
|
38
|
+
arr.Close()
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: BCBvcl4pyAPI
|
|
3
|
-
Version: 0.1.3
|
|
4
|
-
Summary: BCBvcl4pyAPI Python package
|
|
5
|
-
Author-email: James Lin <tylin123@ms27.hinet.net>
|
|
6
|
-
Project-URL: Homepage, https://mis.gotech.biz
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
|
|
9
|
-
Version 0.1.3: 2025/09/19
|
|
10
|
-
--------------
|
|
11
|
-
Mainly fixed the issue where Packages could not be found after an update.
|
bcbvcl4pyapi-0.1.3/PKG-INFO
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: BCBvcl4pyAPI
|
|
3
|
-
Version: 0.1.3
|
|
4
|
-
Summary: BCBvcl4pyAPI Python package
|
|
5
|
-
Author-email: James Lin <tylin123@ms27.hinet.net>
|
|
6
|
-
Project-URL: Homepage, https://mis.gotech.biz
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
|
|
9
|
-
Version 0.1.3: 2025/09/19
|
|
10
|
-
--------------
|
|
11
|
-
Mainly fixed the issue where Packages could not be found after an update.
|
bcbvcl4pyapi-0.1.3/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|