Skip to content

Commit 88bd0ca

Browse files
fix: python sdk insert row and test main (#2129)
1 parent 053c4e3 commit 88bd0ca

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

python/openmldb/dbapi/dbapi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,16 @@ def executemany(self, operation, parameters: Union[List[tuple], List[dict]], bat
377377
if not ok:
378378
raise DatabaseError("get insert builder fail")
379379
schema = builder.GetSchema()
380-
hole_pairs = build_sorted_holes(builder.GetHoleIdx())
380+
hole_idxes = builder.GetHoleIdx()
381+
hole_pairs = build_sorted_holes(hole_idxes)
381382
for i in range(0, parameters_length, batch_number):
382383
rows = parameters[i: i + batch_number]
383384
ok, batch_builder = self.connection._sdk.getInsertBatchBuilder(
384385
self.db, command)
385386
if not ok:
386387
raise DatabaseError("get insert builder fail")
387388
self.__insert_rows(
388-
rows, hole_pairs, schema, batch_builder, command)
389+
rows, hole_idxes, hole_pairs, schema, batch_builder, command)
389390
else:
390391
ok, rs = self.connection._sdk.executeSQL(self.db, command)
391392
if not ok:

python/test/dbapi_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import pytest
1817
import logging
1918
import sys
20-
21-
from case_conf import OpenMLDB_ZK_CLUSTER, OpenMLDB_ZK_PATH
19+
import os
2220
from openmldb.dbapi import connect
2321
from openmldb.dbapi import DatabaseError
22+
import pytest
23+
24+
from case_conf import OpenMLDB_ZK_CLUSTER, OpenMLDB_ZK_PATH
2425

2526
logging.basicConfig(level=logging.WARNING)
2627

@@ -76,4 +77,4 @@ def test_custom_order_insert(self):
7677

7778

7879
if __name__ == "__main__":
79-
sys.exit(pytest.main(["-vv", "dbapi_test.py"]))
80+
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))

python/test/openmldb_client_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import os
1718
import logging
1819
import sys
1920
from datetime import date
@@ -253,4 +254,4 @@ def test_more_parameterized_query(self):
253254

254255

255256
if __name__ == "__main__":
256-
sys.exit(pytest.main(["-vv", "openmldb_client_test.py"]))
257+
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))

python/test/sdk_smoke_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
import pytest
1716

17+
import os
1818
import case_conf
1919
import time
2020

@@ -25,6 +25,7 @@
2525
# add parent directory
2626
sys.path.append(Path(__file__).parent.parent.as_posix())
2727
from openmldb.sdk import sdk as sdk_module
28+
import pytest
2829
# fmt:on
2930

3031

@@ -104,4 +105,4 @@ def test_sdk_smoke():
104105

105106

106107
if __name__ == "__main__":
107-
sys.exit(pytest.main(["-vv", "sql_smoke_test.py"]))
108+
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))

python/test/sql_magic_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
import sys
17-
17+
import os
1818
import openmldb
1919
import pytest
2020
import logging
@@ -79,4 +79,4 @@ def test_drop(self):
7979

8080

8181
if __name__ == "__main__":
82-
sys.exit(pytest.main(["-vv", "sql_magic_test.py"]))
82+
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))

python/test/sqlalchemy_api_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import os
1718
import logging
1819
import sys
1920
import pytest
@@ -58,4 +59,4 @@ def teardown_class(self):
5859

5960

6061
if __name__ == "__main__":
61-
sys.exit(pytest.main(["-vv", "sqlalchemy_api_test.py"]))
62+
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))

0 commit comments

Comments
 (0)