Skip to content

Commit

Permalink
fix: python sdk insert row and test main (4paradigm#2129)
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetablechicken authored Jul 8, 2022
1 parent 053c4e3 commit 88bd0ca
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions python/openmldb/dbapi/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,16 @@ def executemany(self, operation, parameters: Union[List[tuple], List[dict]], bat
if not ok:
raise DatabaseError("get insert builder fail")
schema = builder.GetSchema()
hole_pairs = build_sorted_holes(builder.GetHoleIdx())
hole_idxes = builder.GetHoleIdx()
hole_pairs = build_sorted_holes(hole_idxes)
for i in range(0, parameters_length, batch_number):
rows = parameters[i: i + batch_number]
ok, batch_builder = self.connection._sdk.getInsertBatchBuilder(
self.db, command)
if not ok:
raise DatabaseError("get insert builder fail")
self.__insert_rows(
rows, hole_pairs, schema, batch_builder, command)
rows, hole_idxes, hole_pairs, schema, batch_builder, command)
else:
ok, rs = self.connection._sdk.executeSQL(self.db, command)
if not ok:
Expand Down
9 changes: 5 additions & 4 deletions python/test/dbapi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest
import logging
import sys

from case_conf import OpenMLDB_ZK_CLUSTER, OpenMLDB_ZK_PATH
import os
from openmldb.dbapi import connect
from openmldb.dbapi import DatabaseError
import pytest

from case_conf import OpenMLDB_ZK_CLUSTER, OpenMLDB_ZK_PATH

logging.basicConfig(level=logging.WARNING)

Expand Down Expand Up @@ -76,4 +77,4 @@ def test_custom_order_insert(self):


if __name__ == "__main__":
sys.exit(pytest.main(["-vv", "dbapi_test.py"]))
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))
3 changes: 2 additions & 1 deletion python/test/openmldb_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import logging
import sys
from datetime import date
Expand Down Expand Up @@ -253,4 +254,4 @@ def test_more_parameterized_query(self):


if __name__ == "__main__":
sys.exit(pytest.main(["-vv", "openmldb_client_test.py"]))
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))
5 changes: 3 additions & 2 deletions python/test/sdk_smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest

import os
import case_conf
import time

Expand All @@ -25,6 +25,7 @@
# add parent directory
sys.path.append(Path(__file__).parent.parent.as_posix())
from openmldb.sdk import sdk as sdk_module
import pytest
# fmt:on


Expand Down Expand Up @@ -104,4 +105,4 @@ def test_sdk_smoke():


if __name__ == "__main__":
sys.exit(pytest.main(["-vv", "sql_smoke_test.py"]))
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))
4 changes: 2 additions & 2 deletions python/test/sql_magic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import sys

import os
import openmldb
import pytest
import logging
Expand Down Expand Up @@ -79,4 +79,4 @@ def test_drop(self):


if __name__ == "__main__":
sys.exit(pytest.main(["-vv", "sql_magic_test.py"]))
sys.exit(pytest.main(["-vv", os.path.abspath(__file__)]))
3 changes: 2 additions & 1 deletion python/test/sqlalchemy_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import logging
import sys
import pytest
Expand Down Expand Up @@ -58,4 +59,4 @@ def teardown_class(self):


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

0 comments on commit 88bd0ca

Please sign in to comment.