bulkcopy_arrow() / bulkcopy()` broken in 1.16.0
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 72/100
Línea de trabajo
Start by reading mssql_python/cursor.py at the bulkcopy_arrow() implementation and trace how it imports and uses mssql_py_core; inspect the corresponding bulkcopy() path too. Reproduce the reported import behavior with the 1.16.0 Windows package and check where the connection classes are exposed. Done when both bulk copy methods can access the connection class after a clean 1.16.0 install.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Title
bulkcopy_arrow() / bulkcopy() broken in 1.16.0: AttributeError: module 'mssql_py_core' has no attribute 'PyCoreConnection'
Description
After upgrading from 1.15.0 to 1.16.0, any call to cursor.bulkcopy_arrow(...) (and presumably cursor.bulkcopy(...), which shares the same pycore connection path) fails immediately with:
AttributeError: module 'mssql_py_core' has no attribute 'PyCoreConnection'
Full traceback:
File ".../site-packages/mssql_python/cursor.py", line 3764, in bulkcopy_arrow
pycore_connection = mssql_py_core.PyCoreConnection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'mssql_py_core' has no attribute 'PyCoreConnection'
This reproduces on a clean pip install mssql-python==1.16.0 with no other code changes — the exact same script works correctly against 1.15.0.
Root cause
This looks like a packaging regression from the 1.16.0 change that split the Rust runtime out into a separate version-matched mssql-python-rs package (per the 1.16.0 release notes).
On Windows, after pip install mssql-python==1.16.0, the compiled extension lands at:
site-packages/mssql_py_core/mssql_py_core.pyd
There is no __init__.py inside site-packages/mssql_py_core/. As a result, import mssql_py_core resolves to an empty implicit namespace package (PEP 420) rather than loading the compiled extension — so mssql_py_core.PyCoreConnection doesn't exist at that path.
The compiled extension itself is fine and fully functional — it just needs to be imported one level deeper:
import mssql_py_core.mssql_py_core as core
print([a for a in dir(core) if "Connection" in a])
# -> ['PyAsyncConnection', 'PyCoreConnection']
But mssql_python/cursor.py's bulkcopy_arrow (and likely bulkcopy) does a plain top-level import mssql_py_core and then calls mssql_py_core.PyCoreConnection(...) directly, which hits the empty namespace package instead of the real module.
Likely fix: either (a) add an __init__.py to the mssql_py_core package in the mssql-python-rs wheel that re-exports from the nested mssql_py_core.mssql_py_core extension module, or (b) update mssql-python's internal imports to reference mssql_py_core.mssql_py_core explicitly.
Environment
mssql-python: 1.16.0 (regression; works correctly on 1.15.0)mssql-python-rs: 0.3.0mssql-python-odbc: 18.6.2.2- Python: 3.11.0
- OS: Windows 10/11 (
Windows-10-10.0.26200-SP0), x86_64 - Install method:
pip install mssql-python==1.16.0(clean upgrade from 1.15.0 in an existing venv)
Reproduction steps
pip install mssql-python==1.16.0
python -c "
import mssql_python
cn = mssql_python.connect('SERVER=...;DATABASE=...;Trusted_Connection=yes;')
cur = cn.cursor()
cur.bulkcopy_arrow('some_table', some_pyarrow_record_batch_reader)
"
Minimal repro of the underlying import issue (no SQL Server connection needed):
import mssql_py_core
print(mssql_py_core.__file__) # None -- confirms empty namespace package
print(hasattr(mssql_py_core, "PyCoreConnection")) # False
import mssql_py_core.mssql_py_core as core
print(core.__file__) # points to the real .pyd
print(hasattr(core, "PyCoreConnection")) # True
Expected behavior
import mssql_py_core should expose PyCoreConnection (and PyAsyncConnection) at the top level, as it presumably did before the 1.16.0 packaging split, so bulkcopy_arrow()/bulkcopy() work without modification.
Actual behavior
bulkcopy_arrow() / bulkcopy() are completely broken on 1.16.0 for Windows installs via pip, with no workaround short of pinning back to 1.15.0.
Impact
This blocks all bulk-copy / Arrow bulk-load workflows on 1.16.0. We've rolled back to 1.15.0 in the meantime.
- Lenguaje dominante
- Python
- Estrellas
- 479
- Forks
- 62
- Merge medio
- 2 d 9 h
- PR fusionados (30 d)
- 18
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/mssql-python
-
Pooled connection checkout has no timeout: connect() hangs ~16 min on a dead socketPosiblemente ocupada @jahnvi480 la tomó hace 1 día. Abiertoarea: connectivity-auth bug inADO triage done under development
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
microsoft/mssql-python#854 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
triage needed
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
microsoft/mssql-python#850 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
bulkcopy() & bulkcopy_arrow() fail with Schannel AcquireCredentialsHandleW error 0x8009030D (SEC_E_UNKNOWN_CREDENTIALS)Posiblemente ocupada @jahnvi480 la tomó hace 3 días. Abiertoarea: bulk-copy bug inADO triage done
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
microsoft/mssql-python#848 · 5 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
macOS: encrypted connections fail after Homebrew moved the `openssl` alias to `openssl@4`Posiblemente ocupada @bewithgaurav la tomó hace 23 días. Abiertoarea: packaging-platform bug triage needed
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
microsoft/mssql-python#826 · 2 comentarios · 3 reacciones · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Announcement: mssql-python is coming to Django through mssql-django 2.0Quizá libre de nuevo @bewithgaurav la tomó hace 50 días y no hay ningún pull request abierto. Abiertoannouncement
microsoft/mssql-python#748 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/mssql-python
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
sergey-miryanov/gcmon#230 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
Los mantenedores suelen responder en 1 día
-
[BUG] Failed archive extraction deletes the dataset cachePosiblemente ocupada @dajiaohuang la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
alibaba/GraphScope#4674 ·