Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

Expand Down
31 changes: 3 additions & 28 deletions .github/workflows/ubuntu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
name: Run tests on Python ${{ matrix.python-version }}
# ubuntu-20.04 supports more versions of Python than ubuntu-22.04
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.12"]

services:

Expand Down Expand Up @@ -40,25 +40,12 @@ jobs:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2022

postgres:
image: postgres:13
env:
POSTGRES_DB: postgres_db
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_pwd
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:

- name: Start MySQL service
run: |
sudo systemctl start mysql.service

- name: Check initial setup
run: |
sudo apt-get install unixodbc unixodbc-dev
echo '*** echo $PATH'
echo "$PATH"
echo "*** odbcinst -j"
Expand Down Expand Up @@ -186,19 +173,7 @@ jobs:
echo "*** pyodbc drivers"
python -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"

- name: Run PostgreSQL tests
env:
PYODBC_POSTGRESQL: "DRIVER={PostgreSQL Unicode};SERVER=localhost;PORT=5432;UID=postgres_user;PWD=postgres_pwd;DATABASE=test"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/postgresql_test.py"

- name: Run MySQL tests
env:
PYODBC_MYSQL: "DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;UID=root;PWD=root;DATABASE=test;CHARSET=utf8mb4"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/mysql_test.py"

- name: Run SQL Server 2017 tests
env:
Expand Down
48 changes: 48 additions & 0 deletions tests/sqlserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,54 @@ def test_emoticons_as_literal(cursor: pyodbc.Cursor):
assert result == v



def performance_test(cursor: pyodbc.Cursor):
# benchmark_column_bind_vs_fastexecmany.py
# Setup: drop/create test table
cursor.execute("DROP TABLE IF EXISTS test_perf")
cursor.execute("""
CREATE TABLE test_perf
(
id INT,
value FLOAT,
description VARCHAR(100),
created_at DATETIME
)
""")

# Generate data
rowcount = 10000
data = [
(i, float(i) * 1.1, f"row {i}", datetime.datetime(2020, 1, (i % 28) + 1, 12, 0, 0))
for i in range(rowcount)
]

# Method 1: fast_executemany=False
cursor.fast_executemany = False
start = time.time()
cursor.executemany("INSERT INTO test_perf VALUES (?, ?, ?, ?)", data)
end = time.time()
print(f"executemany: {end - start:.3f} seconds")

# Method 2: fast_executemany
cursor.fast_executemany = True
start = time.time()
cursor.executemany("INSERT INTO test_perf VALUES (?, ?, ?, ?)", data)
end = time.time()
print(f"fast_executemany: {end - start:.3f} seconds")

# # Method 3: column_bind_insert
# # Assuming your pyodbc build exposes column_bind_insert on Cursor
# start = time.time()
# cursor.column_bind_insert("INSERT INTO test_perf VALUES (?, ?, ?, ?)", data)
# end = time.time()
# print(f"column_bind_insert: {end - start:.3f} seconds")

# Verify inserted rows count
cursor.execute("SELECT COUNT(*) FROM test_perf")
print("Total rows inserted:", cursor.fetchone()[0])


def _test_tvp(cursor: pyodbc.Cursor, diff_schema):
# Test table value parameters (TVP). I like the explanation here:
#
Expand Down
Loading